Created
April 18, 2017 05:07
-
-
Save kuldeeprishi/eacfc91723d85edc1c4ecfb3f3c82f68 to your computer and use it in GitHub Desktop.
Threaded Simple HTTPServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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