Python 如何更正烧瓶注册页
如何使我的注册页不创建403错误。这是我的Python 如何更正烧瓶注册页,python,flask,Python,Flask,如何使我的注册页不创建403错误。这是我的/register页面的应用程序路径,其中似乎有错误 @app.route("/register", methods=["GET", "POST"]) def register(): if request.method == "POST": # Making sure the user actually typed in something in th
/register
页面的应用程序路径
,其中似乎有错误
@app.route("/register", methods=["GET", "POST"])
def register():
if request.method == "POST":
# Making sure the user actually typed in something in the fields
username = request.form.get("username")
password = request.form.get("password")
password_confirm = request.form.get("password_confirm")
if not username or not password or not password_confirm:
return apology("invalid username and/or password", 403)
# Making sure there is no other user with the same username
existing_users = db.execute("SELECT * FROM users WHERE username = :username")
if len(existing_users) != 0:
return apology("Please select another username", 409)
if password != password_confirm:
return apology("Your passowords do not match. Please try again!", 409)
hashed_password = generate_password_hash(password)
db.execute("INSERT INTO users (username, hash) VALUES (:username, :password)")
else:
return render_template("register.html")
"""Register user"""
返回后的方法?我想您应该在方法post:returnredirect(“login.html”)的末尾添加代码