From 8406e2d3f39858b5b8b820e9bb22931e5b97dbcb Mon Sep 17 00:00:00 2001 From: max/sooulix Date: Tue, 5 Nov 2024 11:51:54 +0100 Subject: [PATCH] debug json post data --- server.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 server.py 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) +