Flask RuntimeError:会话不可用,因为使用Flask-Session时未设置密钥

时间:2017-04-19 14:50:30

标签: python heroku flask

由于此错误,我的heroku应用程序不允许我注册

run.py

然而,我把会话密钥设置得很好,

from app import app, db, manager, sess import os app.config['SESSION_TYPE'] = 'filesystem' app.config['SECRET_KEY'] = 'reds209ndsldssdsljdsldsdsljdsldksdksdsdfsfsfsfis' sess.init_app(app) app.secret_key() if __name__ == "__main__": app.debug = True; app.run() # manager.run()

__init__.py

from flask import Flask from flask_session import Session app = Flask(__name__) sess = Session() sess.init_app(app) app.config['SESSION_TYPE'] = 'memcached' app.config['SECRET_KEY'] = 'redsfsfsfsfis' from app import views, db

<use>

我已经看过secret key not set in flask session,但它并没有解决我的问题。

1 个答案:

答案 0 :(得分:0)

感谢大卫,我想出来了,

我必须把

sess.init_app(app)

app.config['SECRET_KEY'] = 'redsfsfsfsfis'