Env. Variables not set while running Minimal Flask application
If you are using powershell it does not works i dont know why
please use cmd.exe
since i use VScode editor it provide powershell as a terminal(ctrl + back-tick
) by default so i was trying to run flask app on the powershell and it was giving me same response as you are getting
open cmd.exe (or if you are VSCode user like me simply write
cmd
on that terminal, or you can also pressCtrl + Shift + C
to open a windowed cmd terminal)set FLASK_APP=hello.py
(without spaces, only for first run then it remember until restart of cmd)flask run
(or just flask will also work)
note: this is only for windows user
export FLASK_APP=run.py
flask run --host=0.0.0.0
then can run normally, output something like:
* Serving Flask app "hello"
* Forcing debug mode on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 353-795-063
I faced the same issue while using PowerShell and that fix worked for me:
instead of using set FLASK_APP = run.py
, try $env:FLASK_APP = "run.py"