python - How to return redirect response in aiohttp.web sever -


how return response http redirect in aiohttp server handler?

from documentation:

aiohttp.web defines set of exceptions every http status code.

each exception subclass of httpexception , relates single http status code.

the exceptions subclass of response, allowing either raise or return them in request handler same effect.

the following snippets same:

async def handler(request):     return aiohttp.web.httpfound('/redirect') 

and:

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

link: http://aiohttp.readthedocs.io/en/stable/web.html#exceptions


Comments