Hi Python friends,
I have an issue with my environment variable. The .env file is in the root folder (worksample) and the code is in worksample/work_ex/dash I followed the instructions here: https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/
My WSGI file looks like this:
# This file contains the WSGI configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Flask project
import sys
import os
from dotenv import load_dotenv
project_folder = os.path.expanduser('~/worksample')
load_dotenv(os.path.join(project_folder, '.env'))
# add your project directory to the sys.path
project_home = '/home/worksample/work_ex'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from dash_app.main import app
application = app.server
# from flask_app import app as application # noqa
And in the code of my project, I have the following lines:
import os
KEY = os.getenv("KEY")
holidays = requests.get(f"https://calendarific.com/api/v2/holidays?&api_key={KEY}&country={country_code}&year=2023").text
Did I miss something?
Thank y'all for your help