我正在使用燒瓶設計這個簡單的網站。但是我的hello方法出現了404錯誤。每當我點擊按鈕「率藝術家」,它給我的錯誤,但home.html,hello.html和artist.html模板都是正確的。我不知道我的代碼的哪一部分是錯的。任何幫助?Python燒瓶得到404未找到錯誤
@app.route("/",methods=['GET','POST'])
def login():
if request.method=="GET":
return render_template("home.html")
if request.method=="POST":
if (request.form["button"]=="login"):
return render_template("hello.html",name=request.form["name"])
@app.route("/hello",methods=['GET','POST'])
def hello():
if request.method=="GET":
if(request.form["button"]=="rate artists"):
return render_template("artist.html")
正如你所知,你的'if'語句看起來像'if(...):',而他們工作,實際上並不是普遍接受的約定。例如:倒數第二行: 'if request.form ['button'] =='rate artists':' – jdotjdot
此外,您還需要提供更多信息供人幫助。只是說,如果你沒有提供關於按鈕的信息,那麼「rate artists」按鈕不起作用就無濟於事。 – jdotjdot
「/ hello?button = rate + artists」是否也返回404錯誤? –