I am trying to activate debug mode in Flask.
What I have tried so far:
load_dotenv()
and os.getenv('FLASK_ENV')
and it shows that the value of FLASK_ENV is development
None of the above enabled the debug mode of Flask. FLASK_APP variable is correctly set and read though. Only by running Flask --debug run
activates the debug mode.
Why is the FLASK_ENV variable not recognized by Flask?
As pointed out by ivvija: In Flask version 2.3.0, the FLASK_ENV
environment variable (including the ENV
config key and app.env
property) has been removed.
You should instead set FLASK_DEBUG=1
, or set debug=True
in your app.run()
method or use the --debug
option when running the flask run
command to enable debug mode - any of these will work.