0
我想在sida2中创建一个按钮,然后将我带到resultat并从输入表单中发布名为MJ的信息,但出现错误404请求的URL未找到服务器,我不明白为什么。这是HTML的一部分:404找不到“请求的URL未找到”
<form action="/sida2/resultat.html" method="POST">
<input title="" placeholder="MJ/kq foder" type="text" name="MJ" required>
<br>
<button type="submit">Submit</button>
</form>
这是蟒蛇部分:
from flask import Flask, render_template, request
app=Flask(__name__)
@app.route('/')
def home():
return(render_template("hemsida.html"))
@app.route('/sida2/', methods=['POST', 'GET'])
def sida2():
return(render_template("andrasidan.html"))
@app.route('/sida2/resultat', methods=['POST'])
def resultat():
if request.method=='POST':
mj= request.form["MJ"]
return(render_template("resultat.html"))
if __name__ =="__main__":
app.run(debug=True)
我认为这件事情很明显,我失踪,但我似乎无法找到它。
看起来你的表单看起来像'action'应该会碰到'/ sida1/resultat'端点,而不是'.html'文件。 –