为什么我在 Python 中收到 BadRequestKeyError?

Why am I getting a BadRequestKeyError in Python?

当我尝试 运行 python 中的以下代码时出现此错误。

Error Message

我的signup.html代码:

<html>

<head>
  <title>Signup</title>
  <link href="../static/styles/bookreview.css" rel="stylesheet" 
  type="text/css">
</head>

<body>

<!--Specifying navigation bar-->
<nav>
    <img id="logo" src="../static/images/OUAT Logo.png" alt="Once Upon A Time Logo">
    <ul>
        <li><a href="/">Home</a></li>
        <li><a href="Review Books">Books</a></li>
        <li><a href="Guestbook">Guestbook</a></li>
        <li><a href="Contact Us">Contact</a></li>
    </ul>
    <img id="searchicon" src="../static/images/Search Icon.png">
    <form>
        <input id=searchbar type=text>
    </form>
    <a href="Login"><button id=navsignin>Sign in</button></a>
</nav>

<div class="containers signupcontainer">
    <img id=signupgraphic src="../static/images/signupgraphic.png">
    <h2>Create an account and start <font color="#FF6572">commenting!</font>
    </h2>
    <!--{{msg}}-->
    <form action="" method="POST">
        <label>Full Name</label>
        <input class=signupfields type="text">

        <label>E-mail address</label>
        <input class=signupfields type="text">

        <label>Enter new password</label>
        <input class=signupfields type="password">

        <label>Re-enter password</label>
        <input class=signupfields type="password">

        <button class="buttons signupbutton">Create account</button>
    </form>
</div>
</body>

</html>

我的python代码:

from flask import Flask, redirect, request, url_for, render_template
app = Flask(__name__, static_folder='static')
import sqlite3 as s
DB_FILE = 'mydb'
connection = s.connect(DB_FILE, check_same_thread=False)

@app.route('/')
def index():
   return render_template('Index.html')


@app.route('/Review Books')
def review():
   return render_template('Review.html')

@app.route('/Guestbook')
def guestbook():
   return render_template('Guestbook.html')


@app.route('/Contact Us')
def contact():
   return render_template('Contact.html')

@app.route('/Login')
def login():
   return render_template('Login.html')

def _insertuser(name, email, password, repeatpass):
   params = {'name': name, 'email': email, 'password': password, 
  'repeatpass': repeatpass}
   cursor = connection.cursor()
   cursor.execute("insert into users(name, email, password, repeatpass) 
   values (:name, :email, :password, :repeatpass)", params)
   connection.commit()

@app.route('/Signup', methods=['POST', 'GET'])
   def signup():
      if request.method == 'POST':
         _insertuser(request.form['name'], request.form['email'], 
         request.form['password'], request.form['repeatpass'])
         return render_template('Signup.html', msg=" thank you for signing 
         up")
      else:
         return render_template('Signup.html')

if __name__ == '__main__':
   app.run(debug=True)

My signup form

我看到过类似的问题,我也一直在进行更正,但我仍然遇到这个错误。有人可以帮助我理解为什么会出现此错误以及我是否遗漏了任何内容。

感谢您的宝贵时间。

它缺少 <input>

name 属性
<form action="" method="POST">
    <label>Full Name</label>
    <input name="name" class=signupfields type="text">

    <label>E-mail address</label>
    <input name="email" class=signupfields type="text">

    <label>Enter new password</label>
    <input name="password" class=signupfields type="password">

    <label>Re-enter password</label>
    <input name="repeatpass" class=signupfields type="password">

    <button class="buttons signupbutton">Create account</button>
</form>