commit 8406e2d3f39858b5b8b820e9bb22931e5b97dbcb Author: max/sooulix Date: Tue Nov 5 11:51:54 2024 +0100 debug json post data diff --git a/server.py b/server.py new file mode 100644 index 0000000..ee69c28 --- /dev/null +++ b/server.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import sys +import json +from pprint import pprint + +from http.server import HTTPServer, BaseHTTPRequestHandler + +class DebugHTTPRequestHandler(BaseHTTPRequestHandler): + def do_POST(self): + print(self.headers) + self.send_response(200, '') + data = self.rfile.read(int(self.headers['Content-Length'])) + pprint(json.loads(data)) + self.flush_headers() + + +def __main__(args): + with HTTPServer(args, DebugHTTPRequestHandler).serve_forever() as exc: + print(exc) + + +if __name__ == '__main__': + params_tuple = (sys.argv[1].split(':')[0], int(sys.argv[1].split(':')[1])) + __main__(params_tuple) +