Skip to content

Instantly share code, notes, and snippets.

@mrkschan
Last active September 15, 2022 09:33
Show Gist options
  • Save mrkschan/32e9aaa0f117af44f1eac27fcd48bfa1 to your computer and use it in GitHub Desktop.
Save mrkschan/32e9aaa0f117af44f1eac27fcd48bfa1 to your computer and use it in GitHub Desktop.
import http.server
import socketserver
PORT = 8080
class H(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
print(self.raw_requestline)
print(self.headers)
self.wfile.write(self.raw_requestline)
self.wfile.write(self.headers)
def do_POST(self):
ins = self.rfile.read(int(self.headers.get('Content-Length', 0)))
print(self.raw_requestline)
print(self.headers)
print(ins)
self.send_response(200)
self.end_headers()
self.wfile.write(self.raw_requestline)
self.wfile.write(self.headers)
self.wfile.write(ins)
Handler = H
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