Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup environment variables for `flask run` on Windows?

Tags:

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" ?

error message

like image 682
user9818569 Avatar asked Jul 01 '18 00:07

user9818569


People also ask

How do I run a flask program on Windows?

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 .


1 Answers

Windows PowerShell

set FLASK_APP=hello.py $env:FLASK_APP = "hello.py" flask run 
like image 195
Deepak Gautam Avatar answered Sep 20 '22 05:09

Deepak Gautam