aiohttp - 设置 cookie 然后重定向用户
aiohttp - Set a cookie and then redirect the user
我正在使用 python aiohttp 库编写 Web 服务器。
如何设置 cookie,然后在一个响应中将用户重定向到另一个页面?
可以使用 aiohttp.web.HTTPSeeOther
重定向用户,但我找不到附加 cookie 的方法。
只需设置响应的 cookie 值。
import aiohttp
response = aiohttp.web.HTTPSeeOther(<location>)
response.cookies['test'] = '1'
return response
我正在使用 python aiohttp 库编写 Web 服务器。
如何设置 cookie,然后在一个响应中将用户重定向到另一个页面?
可以使用 aiohttp.web.HTTPSeeOther
重定向用户,但我找不到附加 cookie 的方法。
只需设置响应的 cookie 值。
import aiohttp
response = aiohttp.web.HTTPSeeOther(<location>)
response.cookies['test'] = '1'
return response