Last active
September 15, 2022 09:33
-
-
Save mrkschan/32e9aaa0f117af44f1eac27fcd48bfa1 to your computer and use it in GitHub Desktop.
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 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