小编Dr *_*ser的帖子

在烧瓶中设置一个cookie

我正在尝试在烧瓶中创建一个cookie.手册中的部分示例是:

resp = make_response(render_template(...))
resp.set_cookie(’username’, ’the username’)
Run Code Online (Sandbox Code Playgroud)

所以我把它实现为

resp = render_template('show_entries.html', AO_sInteger = session.get('AO_sInteger'))
resp.set_cookie('AO_sInteger', AO_sInteger)
Run Code Online (Sandbox Code Playgroud)

然后系统返回错误:

File "...\Flaskr101.py", line 19, in add_entry
resp.set_cookie('AO_sInteger', AO_sInteger)
AttributeError: 'unicode' object has no attribute 'set_cookie'
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

python cookies flask

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

cookies ×1

flask ×1

python ×1