squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

how can I use redirect in a response? #65

Closed SumonMSelim closed 7 years ago

SumonMSelim commented 7 years ago

I want to redirect my response to an url rather than returning something. At the moment, I am doing it this way:

return request.Response(headers={'Refresh': '0; url=https://github.com/squeaky-pl/japronto'})

Is there any better way?

squeaky-pl commented 7 years ago

Just use standard HTTP way Location header and 30x responses: https://en.wikipedia.org/wiki/URL_redirection#HTTP_status_codes_3xx

vadim-shadrin commented 6 years ago

return request.Response(headers={'Location': '/login'}, code=302) return request.Response(headers={'Location': '/'}, code=302)