烧瓶中未显示Flash消息

时间:2018-11-27 11:06:42

标签: python flash flask

当我登录时没有显示Flash消息。如何解决?

我的登录名低于

@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消息。

1 个答案:

答案 0 :(得分:0)

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

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

相关问题