烧瓶 - 404 未找到

Rox*_*hbi 2 python flask web

我是烧瓶开发的新手,这是我在烧瓶中的第一个程序,但它显示了这个错误:

在服务器上找不到请求的 URL。如果您手动输入了 URL,请检查您的拼写并重试。

&这是我的代码

from flask import Flask

app = Flask(__name__)


@app.route('/index')
def index():
    return 'Hello World'


if __name__ == '__main__':
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

Fat*_*lıç 8

我认为你应该去http://localhost:5000/indexhttp://127.0.0.1:5000/index但如果你想制作那个页面你的代码应该是这样的

from flask import Flask

app = Flask(__name__)


@app.route('/')
def index():
    return 'Hello World'


if __name__ == '__main__':
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

更改@app.route('/index')@app.route('/')你也应该检查这个http://flask.pocoo.org/docs/0.12/quickstart/#routing