flask中未显示flash消息



当我登录时,不会显示flash消息。我该怎么修?

我的登录def低于

@app.route("/login",methods=["GET","POST"])
def login():
form=LoginForm(request.form)
if request.method=="POST":
username=form.username.data
password_entered=form.password.data
cursor=mysql.connection.cursor()
sorgu="Select * From users where username = %s"
result=cursor.execute(sorgu,(username,))
if result>0:
data=cursor.fetchone() 
real_password=data["password"]
if sha256_crypt.verify(password_entered,real_password):
flash("Başarıyla giriş yaptınız...","info")
session["logged_in"]=True
session["username"]=username
return redirect(url_for("index"))
else:
flash(("wrong password","warning"))
return redirect(url_for("login"))
else:
flash("this username is not avaible","warning")
return render_template("login.html",form=form)

我不知道为什么它不起作用。登录后重定向url功能正常工作,但不会出现闪烁消息。

您传入的是一个参数(元组(,而不是两个。

flash(("wrong password","warning"))更改为flash("wrong password","warning")

最新更新