redirect-opt-in.py (601B)
1 def main(request, response): 2 """Simple handler that causes redirection. 3 4 The request should typically have two query parameters: 5 status - The status to use for the redirection. Defaults to 302. 6 location - The resource to redirect to. 7 """ 8 status = 302 9 if b"status" in request.GET: 10 try: 11 status = int(request.GET.first(b"status")) 12 except ValueError: 13 pass 14 15 response.status = status 16 17 location = request.GET.first(b"location") 18 19 response.headers.set(b"Location", location) 20 response.headers.set(b"Timing-Allow-Origin", b"*")