Created
February 13, 2015 06:26
-
-
Save bojieli/60530883caf6bd4bd4c5 to your computer and use it in GitHub Desktop.
A sample http server
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
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