Skip to content

Instantly share code, notes, and snippets.

@flippingbits
Last active December 15, 2025 16:28
Show Gist options
  • Select an option

  • Save flippingbits/ca5c766c7da1e10bf0824c114f585afa to your computer and use it in GitHub Desktop.

Select an option

Save flippingbits/ca5c766c7da1e10bf0824c114f585afa to your computer and use it in GitHub Desktop.
from http.server import BaseHTTPRequestHandler, HTTPServer
import urllib
class SimpleHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path.startswith('/schemas/types'):
self.send_response(200)
self.end_headers()
self.wfile.write(b'["JSON", "PROTOBUF", "AVRO"]')
else:
# Print all request details
print(f"Request path: {self.path}")
print(f"Request headers:\n{self.headers}")
print(f"Client address: {self.client_address}")
print(f"Command: {self.command}")
print(f"Request version: {self.request_version}")
# Query parameters
parsed_url = urllib.parse.urlparse(self.path)
print(f"Query params: {urllib.parse.parse_qs(parsed_url.query)}")
self.send_response(200)
self.end_headers()
self.wfile.write(b'OK')
def run(server_class=HTTPServer, handler_class=SimpleHandler, port=8080):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print(f"Starting server on :{port}")
httpd.serve_forever()
if __name__ == '__main__':
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment