3 # Returns a valid image response when request's |referrer| matches
5 def main(request
, response
):
6 referrer
= request
.headers
.get("referer", "")
7 expected_referrer
= request
.GET
.first("expected_referrer", "")
8 response_headers
= [("Content-Type", "image/png")]
9 if referrer
== expected_referrer
:
10 image_path
= os
.path
.join(os
.path
.dirname(__file__
), "image.png")
11 return (200, response_headers
, open(image_path
, mode
='rb').read())
12 return (404, response_headers
, "Not found")