Skip to content

Instantly share code, notes, and snippets.

@bojieli
Created February 13, 2015 06:26
Show Gist options
  • Save bojieli/60530883caf6bd4bd4c5 to your computer and use it in GitHub Desktop.
Save bojieli/60530883caf6bd4bd4c5 to your computer and use it in GitHub Desktop.
A sample http server
import SimpleHTTPServer
import SocketServer
import urlparse
PORT = 80
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
try:
query = urlparse.parse_qs(urlparse.urlparse(self.path).query)
print query
except:
print "Unrecognizable path " + self.path
self.send_response(200)
httpd = SocketServer.TCPServer(("", PORT), ServerHandler)
print "serving at port", PORT
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment