How to store environment variables in a Python Flask app?
Flask has a custom context to store app variables:
http://flask.pocoo.org/docs/1.0/appcontext/
You can use g object to store your variables:
from flask import g
g.github_token = 'secret'
And after initialization:
from flask import g
token = g.github_token
The simpliest way is to place it into configuration module (regular python .py
file) and then import
and use it in your code as suggested by this snippet on Flask site.