我正在尝试开始使用Flask,但是在hello world程序中我得到了404not Found错误。
我使用的程序:
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/index.html')
def hello_world():
return 'Hello, World'
if __name__== '__main__':
app.run(host='localhost')然后我跑
$export FLASK_APP = minimal.py
$flask run它返回:
* Serving Flask app "minimal"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN 127-804-808
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)当我访问http://localhost:5000或http://127.0.0.1:5000时,我会得到:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.我的主机文件看起来像这样:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost你知道出什么问题了吗?谢谢
发布于 2018-05-27 16:40:23
是的,你可以用以下方法删除错误404not found : 1:你应该写命令netstat -a -b来检查哪个端口空闲或者忙碌;2:写进你的代码app.run(port=4996)而不是app.run(),默认情况下选择端口号50000。
https://stackoverflow.com/questions/48087552
复制相似问题