mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
16 lines
450 B
Python
16 lines
450 B
Python
import cStringIO as StringIO
|
|
import urlparse
|
|
import time
|
|
|
|
def handle_request(req):
|
|
url = urlparse.urlparse(req.path)
|
|
delay = float(int(url.query))
|
|
time.sleep(delay / 1000) # argument is in milliseconds
|
|
|
|
body = "OK ({}ms delayed)\n".format(delay)
|
|
req.send_response(200)
|
|
req.send_header('Content-Type', 'text/plain')
|
|
req.send_header('Content-Length', str(len(body)))
|
|
req.end_headers()
|
|
return StringIO.StringIO(body)
|