我正在使用烧瓶设计这个简单的网站。但是我的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错误? –