【发布时间】:2021-12-10 18:58:48
【问题描述】:
我已经在应用程序引擎上上传了一个 python 烧瓶应用程序,并且我在其中使用了 session 登录页面,并且应用程序在我的本地计算机上运行良好,它们没有错误,但我的应用程序在应用程序引擎,当我看到日志时,我意识到应用程序引擎会在任何时候自动清除会话 cookie 我不知道为什么会这样,因为应用程序在我的本地计算机上运行良好,当应用程序引擎清除我的会话时,程序会重定向我到登录页面,如果根据我的 login_required 装饰器清除会话,这是必要的 所以请给我这个应用引擎错误的解决方案
装饰器功能:-
def login_required(f): @wraps(f) def deco_function(*args, **kwargs): 打印(“嗨”) 打印(会话) 如果在会话中“登录”: 返回 f(*args, **kwargs) 返回重定向(url_for('登录')) 返回装饰函数
登录路径:-
@app.route('/', methods=['GET','POST']) 定义登录():
if request.method == 'POST':
if bcrypt.checkpw(request.form['password'].encode('utf-8'), hashed_pass.encode('utf-8')) and (request.form['user_name'] == firebase_user_name) :
session['loggedin'] = 'admin'
print(session)
return redirect(url_for('dashboard'))
flash('Username or password incorrect')
return render_template('login.html')
【问题讨论】:
标签: python python-3.x flask google-app-engine