Skip to content

Instantly share code, notes, and snippets.

@ykhrustalev
Created June 15, 2017 09:24
Show Gist options
  • Save ykhrustalev/e63b90c592e65b6fda9f62aac34fe706 to your computer and use it in GitHub Desktop.
Save ykhrustalev/e63b90c592e65b6fda9f62aac34fe706 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import SimpleHTTPServer
import SocketServer
import sys
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def do_POST(self):
self.do_GET()
if __name__ == "__main__":
host = ''
port = 8000
if len(sys.argv) == 2:
port = int(sys.argv[1])
elif len(sys.argv) > 2:
host = sys.argv[1]
port = int(sys.argv[2])
server = SocketServer.TCPServer((host, port), ServerHandler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment