[英]How to get rid of BadRequestKeyError?
I am using Python 3. I have created the necessary folders.我正在使用 Python 3. 我已经创建了必要的文件夹。 ie static and templates folder.即 static 和模板文件夹。 Still, this code is not working.尽管如此,此代码仍无法正常工作。 I get the following error werkzeug.exceptions.BadRequestKeyError
我收到以下错误werkzeug.exceptions.BadRequestKeyError
abc.py abc.py
from flask import Flask, request, render_template, redirect
app=Flask(__name__)
@app.route('/project/', methods=['GET', 'POST'])
def tryy():
name=request.method
name1=request.form["uname"]
return render_template("project1.html",name=name1)
if __name__=="__main__":
app.run(debug=True)
project.html项目.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="" method="GET">
<input type="text" name="uname" />
<input type="submit" value="Signup" />
</form>
</body>
</html>
project1.html项目1.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css"
href="{{url_for('static', filename='style.css')}}" />
</head>
<body>
<h1>Hey there {{name}}. Nice to meet you</h1>
</body>
</html>
Your form action is set to "" change it to this: <form action="/project/" method="GET">
您的表单操作设置为“”,将其更改为: <form action="/project/" method="GET">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.