Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anuragrana/9f1e3ca3a6851a0d32feec24140c78b7 to your computer and use it in GitHub Desktop.
Save anuragrana/9f1e3ca3a6851a0d32feec24140c78b7 to your computer and use it in GitHub Desktop.
Threaded Simple HTTPServer
#!/bin/env python
import sys
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server = ThreadingSimpleServer(
('', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
try:
while 1:
sys.stdout.flush()
server.handle_request()
except KeyboardInterrupt:
print "Finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment