debug json post data
This commit is contained in:
commit
8406e2d3f3
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue