I am trying to follow the flask documentation on my windows machine given at the following link: http://flask.pocoo.org/docs/0.11/quickstart/#debug-mode
Firstly I wrote
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"
Your code is correct. Try setting the Command-Line variable like this :
setx FLASK_APP run.py
And then run it : flask run
.
You have to set the FLASK_APP variable outside of the virtual environment. I'm assuming the reason that it worked after @Fang restarted the command window is because that action automatically exited the virtual environment.
So, if you're in the virtual environment (indicated by a (venv)
at the start of line on command window), then type the following commands:
deactivate
set FLASK_APP=run.py
venv\scripts\activate
flask run
Success with setx FLASK_APP test.py
. Note: if not run, close command line and start other one.
D:\projects\flask-oauthlibpy2>.evn\Scripts\activate
(.evn) D:\projects\flask-oauthlibpy2>setx FLASK_APP test.py
SUCCESS: Specified value was saved.
(.evn) D:\projects\flask-oauthlibpy2>flask run
* Serving Flask app "flask-oauthlibpy2.test"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [24/May/2017 14:35:06] "GET / HTTP/1.1" 200 -
Here is what worked for me:
setx FLASK_APP sqlAlchemy.py
python - m flask run
I have an Alienware laptop and am using Windows 10.
Not sure it worked but it was a combination of trial and ever. Depending on the OS you have the solution will vary it seems. IT could be an environmental variable issue but again not sure.
- Here are other possible solutions that didn't work for me but I gathered them up as possibilities.