Sometimes, we want to debug a Python Flask app.
In this article, we’ll look at how to debug a Python Flask app.
How to debug a Python Flask app?
To debug a Python Flask app, we set the FLASK_APP
and FLASK_ENV
environment variables before running the app.
To do this on Linux and Mac, we run
export FLASK_APP=myapp
export FLASK_ENV=development
flask run
to set the environment variables with export
.
And then we run flask run
to run the app.
On Windows, we replace export
with set
in the command prompt.
And in Windows PowerShell, we run
$env:FLASK_ENV = "development"
to set the environment variables with $env:
.
Conclusion
To debug a Python Flask app, we set the FLASK_APP
and FLASK_ENV
environment variables before running the app.