python-如何从aiohttp.web服务器返回重定向响应

如何在aiohttp服务器处理程序中使用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
上一篇:python-如何使用PyCharm运行adev(aiohttp_devtools)命令


下一篇:python-aiohttp:通过域限制每秒请求数