4 from wptserve
.utils
import isomorphic_encode
6 def main(request
, response
):
7 name
= request
.GET
.first(b
"name")
8 sleepTime
= float(request
.GET
.first(b
"sleep")) / 1E3
9 numInitial
= int(request
.GET
.first(b
"numInitial"))
11 path
= os
.path
.join(os
.path
.dirname(isomorphic_encode(__file__
)), name
)
12 body
= open(path
, u
"rb").read()
14 response
.headers
.set(b
"Content-Type", b
"image")
15 response
.headers
.set(b
"Content-Length", len(body
))
16 response
.headers
.set(b
"Cache-control", b
"no-cache, must-revalidate")
17 response
.write_status_headers()
19 # Read from the beginning, |numInitial| bytes.
20 first
= body
[:numInitial
]
21 response
.writer
.write_content(first
)
25 # Read the remainder after having slept.
26 second
= body
[numInitial
:]
27 response
.writer
.write_content(second
)