Revision 83be7773ed3e2df8c2f8625d11ec35358586e48c authored by Anne van Kesteren on 13 March 2018, 17:31:34 UTC, committed by Anne van Kesteren on 13 March 2018, 17:31:34 UTC
See https://github.com/whatwg/html/pull/3562.
1 parent 970fca8
Raw File
redirect.py
def main(request, response):
    """Simple handler that causes redirection.

    The request should typically have two query parameters:
    status - The status to use for the redirection. Defaults to 302.
    location - The resource to redirect to.
    """
    status = 302
    if "status" in request.GET:
        try:
            status = int(request.GET.first("status"))
        except ValueError:
            pass

    response.status = status

    location = request.GET.first("location")

    response.headers.set("Location", location)
back to top