I just started learning flask and I am stuck at setting up the Flask environment variables. I don't know how to setup the environment variables. Whenever I use the flask run
command, I encounter the following error:
Error message : Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.
I did a lot of google searches to setup environment variables on Windows but I am unable to find a solution and sometimes I am not able to understand the solution.
How to do this ? How to get the "app.py" or "wsgi.py" ?
To run the app outside of the VS Code debugger, use the following steps from a terminal: Set an environment variable for FLASK_APP . On Linux and macOS, use export set FLASK_APP=webapp ; on Windows use set FLASK_APP=webapp . Navigate into the hello_app folder, then launch the program using python -m flask run .
Windows PowerShell
set FLASK_APP=hello.py $env:FLASK_APP = "hello.py" flask run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With