问题
I'm trying to run the Hello World using Flask framework :
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello() -> str:
return 'Hell world from Flask!'
app.run()
Then I go to my cmd and I run my script according to the documentation:
set FLASK_APP = flaskhello.py
python -m flask run
And what I get is a grey window with a click me header and when I click it i get the X and Y but I don't get the http address on my cmd to run it on browser. What should I do to correct this ?
I've already installed flask correctly as it seems, but I'm not sure.
edit. I also tried creating a new venv and the same happens
回答1:
You are mixing old and new documentation. You can lose the last line in flaskhello.py (app.run()
). Then, don't pass the flask run
command to python, but run it directly in the CMD. So not python -m flask run
, but flask run
.
来源:https://stackoverflow.com/questions/57345779/flask-not-displaying-http-address-when-i-run-it