当我试图提交这个HTML表单时,它没有,然后我尝试将其作为本地文件,但我遇到了同样的问题,有人能帮忙吗?注意:我对烧瓶很陌生,所以如果一个初学者犯了错误,请原谅我。
这是我的代码(login.html(:
<from action="#" method="post">
<input type="text" name="userName" placeholder="Enter Your Name..."/>
<input type="password" name="passw" placeholder="Enter Your Password..."/>
<input type="submit"/>
</from>
这是我的相关Flask服务器代码:
@app.route("/login/", methods=["POST", "GET"])
def login():
return render_template("login.html")
#not doing anything with the password at the moment.
@app.route("/<user>")
def user(user):
return f"<h1>{user}</h1>"
看起来您使用了一个错误的标记。您的表单未提交,因为您使用了标记。试试这个
<form action="#" method="post">
<input type="text" name="userName" placeholder="Enter Your Name..."/>
<input type="password" name="passw" placeholder="Enter Your Password..."/>
<input type="submit"/>
</form>
此外,您可以使用java脚本使用不带表单标记的提交按钮。