Flask错误设置会话属性:BadPayload

时间:2016-02-24 23:36:38

标签: python session flask

我在设置烧瓶会话属性时遇到问题。我无法在没有BadPayload: Could not load the payload because an exception occurred on unserializing the data错误的情况下将session ['var_name']设置为anythign。以下代码抛出错误。但如果我评论session['a'] = 1并且它运行正常。看起来像是一个危险的错误。我应该将secret_key设置为比gobblygook更好的东西吗?这有关系吗?

from flask import Flask, render_template, session

app = Flask(__name__)
app.secret_key = 'sdfnbsifhosdfsdsfsddfsdfiewl'

@app.route('/', methods=['GET','POST'])
def index():
    session['a'] = 1
    return render_template('index.html')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7777, debug=True)

0 个答案:

没有答案