TL;DR
I don't want to export
my variables every time I log on. I want them in my config.
From the docs
Using the environment variables as described above is recommended. While it is possible to set ENV and DEBUG in your config or code, this is strongly discouraged.
How do I do it anyway? How is it 'possible'?
MORE - What I've Tried
I have a flask.cfg
with FLASK_ENV='development'
. I run flask run
and I get development
printed. But the production server has already started. It ignores the following:
app.config.from_pyfile("flask.cfg")
print(f"{app.config['ENV']}") => development
This is in a personal project of no consequence. That's why I am ignoring best practices for convenience.
unset
the system's environment variable? It might be overwriting the configuration in your file..bashrc/.bash_profile
, where I set manul vars, don't have any python envs I can see. Also I am inside venv. Shouldn't this insulate me from local envs? (I'm new to venv so I don't know)echo $FLASK_ENV
? Your system environment variables will still remain,venv
insulates the Python executable and libraries.$PATH
for example, this not blank, even in venv. So seems venv has access to local system vars.