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
I was having this same problem running the commands as stated in Flask quick start. using Powershell on windows 10
projects>set export FLASK_APP=hello.py
projects>flask run
* Running on http://127.0.0.1:5000/
I needed to type python <filename.py>
while being in the directory containing the file with
from flask import Flask
app = Flask(name)
@app.route('/')
def hello_world():
return 'Hello, World!
after that you will get a message with an IP address in it
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
you copy IP address into your browser and your to that point you should see your hello world statement then.
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+
) by default so i was trying to run flask app on the powershell and it was giving me same response as you are getting
1) open cmd.exe (or if you are VSCode user like me simply write cmd
on that terminal)
2) set FLASK_APP=hello.py
(without spaces, only for first run then it remember until restart of cmd)
3) flask run
(or just flask will also work)
note: this is only for windows user
Just drop the space around '=' !
After half an hour searching for solution, I finally get what does 'You did not provide the FLASK_APP environment variable' mean. Because what I set is 'FLASK_APP ' variable (with space).
I was having the same problem, but the following command worked for me in PowerShell:
python -m flask run
Just drop the space around equal to sign. set FLASK_APP=python_file_name.py
I wonder why this is missing from the answer.
Here is a simple solution:
add app.run(port=5000)
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
app.run(port=5000)
and then in the same directory run the command
python run.app