Skip to content

Instantly share code, notes, and snippets.

@mattvonrocketstein
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save mattvonrocketstein/3973530212151f2ca087 to your computer and use it in GitHub Desktop.

Select an option

Save mattvonrocketstein/3973530212151f2ca087 to your computer and use it in GitHub Desktop.
multithreaded directory server
#!/usr/bin/env python
import sys
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class ThreadingSimpleServer(
SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass
def main():
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"
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment