我找不到这段代码发生了什么错误。帮助我找出解决方案。Error Message为什么sha256_crypt.verify(password,possw_data)输入错误?我找不到解决方法。
from flask import Flask, render_template, request, redirect, url_for, session, flash
import MySQLdb
from passlib.hash import sha256_crypt
@app.route("/login", methods=["GET","POST"])
def login():
if request.method == "POST":
username = request.form["username"]
password = sha256_crypt.encrypt(request.form['password'])
cursor = mydb.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SELECT username FROM user WHERE username ='"+ username +"'")
userdata = cursor.fetchone()
if userdata is None:
flash("Incorrect username","danger")
return render_template("login.html")
else:
for possw_data in userdata:
if sha256_crypt.verify(password,possw_data):
flash("You are now login","success")
return redirect(url_for('profile'))
else:
flash("Incorrect password!")
return render_template("login.html")
return render_template("login.html")