For local development I simply set .env file that contain necessarily variables and just run the app with:
Flask run
Everything seems fine, all the environment variables are being read and set correctly in the app.
However when I run the app with gunicorn:
gunicorn api:app --bind 127.0.0.1:5050
I can see clearly that env variables are not loaded.
Only If I set them explicitly in gunicorn command:
gunicorn api:app --bind 127.0.0.1:5057 -e POSTGRES_DB=postgresql://XXXXX
then it will work. However since I can have many environment variables this is not really feasible. Is there a way to set this using file?