slow-image.py (469B)
1 import os.path 2 import time 3 4 def main(request, response): 5 # Sleep for 500ms to delay the `load` events. 6 time.sleep(0.5) 7 8 name = request.GET.first(b"name") 9 path = os.path.join(os.path.dirname(__file__), name) 10 body = open(path, u"rb").read() 11 12 response.headers.set(b"Content-Type", b"image") 13 response.headers.set(b"Content-Length", len(body)) 14 response.headers.set(b"Cache-control", b"no-cache, must-revalidate") 15 16 response.content = body