Skip to content

Instantly share code, notes, and snippets.

@jwhb
Created January 31, 2023 10:24
Show Gist options
  • Save jwhb/de4225afba72328af443671177666ec5 to your computer and use it in GitHub Desktop.
Save jwhb/de4225afba72328af443671177666ec5 to your computer and use it in GitHub Desktop.
python3 HTTP inspection
#!/usr/bin/python3
import http.server
import socketserver
import logging
PORT=8000
class ServerHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
logging.error(self.headers)
# whatever else you would like to log here
http.server.SimpleHTTPRequestHandler.do_GET(self)
Handler = ServerHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
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