如何 return 重定向来自 aiohttp.web 服务器的响应

How to return redirect response from aiohttp.web server

如何在 aiohttp 服务器处理程序中 return 使用 HTTP 重定向的响应?

文档:http://aiohttp.readthedocs.io/en/stable/web_quickstart.html#redirects

async def handler(request):
    raise web.HTTPFound('/redirect')

异常类及其对应的HTTP状态码:http://aiohttp.readthedocs.io/en/stable/web_quickstart.html#exceptions

  * 300 - HTTPMultipleChoices
  * 301 - HTTPMovedPermanently
  * 302 - HTTPFound
  * 303 - HTTPSeeOther
  * 304 - HTTPNotModified
  * 305 - HTTPUseProxy
  * 307 - HTTPTemporaryRedirect
  * 308 - HTTPPermanentRedirect