0

我刚刚开始学习Flask,但我什至无法完成这个初学者步骤。我试图制作dynamic URL如下路线,但是当我去http://127.0.0.1:5000/home例如,它说"NOT FOUND"。任何帮助表示赞赏!

from flask import Flask

app = Flask(__name__)

@app.route("/") #this is the default domain
def home():
    return "<h1>Hello this main page</h1>"

@app.route("/<name>")
def user(name):
    return f"hi {name}"

if __name__ == "__main__":
    app.run()
4

1 回答 1

0

您忘记设置路线 /home。尝试这个 :)

@app.route("/home")
def home():
    return "<h1>Hello this main page</h1>"
于 2020-07-15T12:54:15.237 回答