Acess Heroku variables from Flask
If you're running your app locally, you can 'pull down' the Heroku environment variables by running:
heroku config:pull --overwrite
This will create a local .env
file which contains your environment variables.
If you then run $ source .env
in your terminal before running your app, these variables will be loaded into the environment for you -- in a manner similar to what Heroku does.
Also, your code looks incorrect.
The way you typically want to access environment variables is like so:
from os import environ# If MY_ENVIRONMENT_VARIABLE doesn't exist, None will be printed.print environ.get('MY_ENVIRONMENT_VARIABLE')