Flask not displaying http address when I run it

核能气质少年 提交于 2021-01-29 08:02:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!