Setting the Flask ENV Variable
This post covers how to set the FLASK_APP environment variable to run Flask.
[01] Setting FLASK_APP
- When you run
flask run, Flask looks forapp.pyorwsgi.pyin the current directory and starts the server. - If you renamed those files, you must set
FLASK_APP=<filename>for it to run correctly.
When the file is named test.py:
1
2
3
4
5
6
7
8
# Linux
export FLASK_APP=test
# PowerShell (Windows 10, VSCode)
$env:FLASK_APP="test.py"
# Bash shell (Windows 10, VSCode)
set FLASK_APP=test