envvar not suitable for Environment Variable . If you use a Linux-based OS (Ubuntu, Mac, etc.), then when you start a regular shell, you probably run bash . To set the environment variable in bash, you simply do:
$ SOME_NAME=some_value
So, in the case of a Flask application configured from the FLASKR_SETTINGS environment FLASKR_SETTINGS , you should:
$ FLASKR_SETTINGS=/path/to/settings/file.ext $ python your_script.py
What Flask does is simply import this file as if it were a regular Python file and pulled every UPPERCASE_ONLY name in the file (any other combination would be ignored).
The same is true for from_object - in fact, from_object can also accept an imported string:
app.config.from_object("importable.configuration")
Finally, note that you do not need to have only one configuration call - you can use several calls:
app.config.from_object("your.package.default.config") app.config.from_envvar("YOUR_APPS_ENVVAR", silent=True)
Sean vieira
source share