홈>
내가 로그인했을 때 플래시 메시지가 표시되지 않습니다. 어떻게 해결할 수 있습니까?
내 로그인 데프가 아래에 있습니다
@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 리디렉션 기능이 작동하지만 플래시 메시지가 표시되지 않습니다.
- 답변 # 1
관련 질문
- python : 플라스크에서 사용자 역할을 어떻게 만드는가?
- CSRF 토큰이 없습니다-Flask WTForms Python
- python : 그러한 파일이나 디렉토리가 없지만 거기에 있습니다.
- javascript : 상태 code 409로 요청 실패 : React Front End &Python Flask Back End
- javascript : 이 파이썬 code를 간단한 HTML 웹 사이트에 삽입하는 방법은 무엇입니까?
- python : SQLAlchemy를 사용하여 Flask에 존재하지 않는 테이블을 생성하려면 어떻게해야합니까?
- python : 유형 오류 : 반환 유형은 문자열, dict, 튜플, 응답 인스턴스 또는 WSGI 호출 가능이어야하지만 목록이었습니다.
- python : Flask-mail send_email ()은 예외를 생성하고 RunTimeError : Working outside of application context
- python : Bigquery를 사용하는 CRUD 웹 애플리케이션?
- python : 멀티도 커 작업자 애플리케이션의 셀러리
두 개의 인수 대신 하나의 인수 (튜플)를 전달하고 있습니다.
와이즈 비즈 변경
flash(("wrong password","warning"))
로flash("wrong password","warning")