python+flask+session写供前端使用的后台接口,实现登录保存session时报错。

时间:2024-04-27 23:06:17

RuntimeError: The session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.

解决办法是

 app = Flask(__name__)
app.config['SECRET_KEY'] = ''

session 必须带有['SECRET_KEY'] ,可以随机写一个,也可以自己使用python自带生成随机数模块,生成一个写上。