26 lines
661 B
Python
26 lines
661 B
Python
#!/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)
|
|
|