I have some environment variables stored under /home/postpulser/mysite/.env
that I want my flask app to load.
I followed this and this and my WSGI file now 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
# add your project directory to the sys.path
project_home = u'/home/postpulser/mysite'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# project_folder = os.path.expanduser('~/mysite') # adjust as appropriate
load_dotenv('/home/postpulser/mysite/.env')
# import flask app but need to call it "application" for WSGI to work
from flask_app import app as application # noqa
However, when I try to reload the app, it does not update, and I get: "Your webapp took a long time to reload. It probably reloaded, but we were unable to check it." .
The problem apparently lies in the load_dotenv('/home/postpulser/mysite/.env')
line. When I remove it, the app reloads (but of course the .env variables are not loaded if I do so).
Any ideas on how to fix this?