Skip to content

Instantly share code, notes, and snippets.

@kylemcdonald
Created September 21, 2014 01:24
Show Gist options
  • Save kylemcdonald/3bb71e4b901c54073cbc to your computer and use it in GitHub Desktop.
Save kylemcdonald/3bb71e4b901c54073cbc to your computer and use it in GitHub Desktop.
Python POST simple server
import SimpleHTTPServer
import SocketServer
PORT = 8000
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_POST(self):
content_len = int(self.headers.getheader('content-length', 0))
post_body = self.rfile.read(content_len)
print post_body
Handler = ServerHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
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