Skip to content

Instantly share code, notes, and snippets.

@darekmydlarz
Forked from raelmax/server.py
Created September 21, 2017 12:48
Show Gist options
  • Save darekmydlarz/d48d02de6b3a55afa571178669dde865 to your computer and use it in GitHub Desktop.
Save darekmydlarz/d48d02de6b3a55afa571178669dde865 to your computer and use it in GitHub Desktop.
Python SimpleHTTPServer com sleep
import SimpleHTTPServer
import SocketServer
from time import sleep
PORT = 5000
SLEEP_TIME = 6
class SlowHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
sleep(SLEEP_TIME)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Handler = SlowHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment