📜  烧瓶中的会话 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:28.996000             🧑  作者: Mango

代码示例2
@app.route("/login",methods = ["POST","GET"])  
    def login():  
        if request.method == "POST":  
            try:   
                Email = request.form["email"]
                pwd = request.form["pwd"]    
                with sqlite3.connect("Account.db") as con:  
                    cur = con.cursor()
                    print("Connection test")   
                    cur.execute("SELECT * FROM Account WHERE Email= ? and Password= ?",(Email, pwd))
                    row = cur.fetchone()
                    print("query test")  
                    while row is not None:
                        session['email']=request.form['email']  
                        print(row[1])
                        return render_template("success.html",msg = msg)
                    else:
                        msg = "sorry wrong id"
                        return render_template("failure.html",msg = msg)
            except:  
                con.rollback()  
                msg = "problem"  
#In the other function do :
 if 'email' in session:
        email = session['email']   
        return render_template("view.html") 
    else:
        return '

Please login first

'