Skip to content

Instantly share code, notes, and snippets.

@ohhdemgirls
Created August 3, 2017 01:54
Show Gist options
  • Save ohhdemgirls/41e4006d3eef2631034eda6145c4d0f5 to your computer and use it in GitHub Desktop.
Save ohhdemgirls/41e4006d3eef2631034eda6145c4d0f5 to your computer and use it in GitHub Desktop.
Multi-threaded python httpd
#!/bin/env python
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass
import sys
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