main.py737 chars27 lines
This code creates an HTTP server in Python listening on port 8000. It expects a POST request with a binary payload, reads the payload into memory, does some binary processing on the payload and returns a binary response. When a POST request is received, do_POST
function is called. It reads the request body from rfile
and stores it in the body
variable. The binary processing happens in the middle which can vary according to the use case. The response is returned in a similar way, by encoding the binary content in output
variable and sending it back as response.
gistlibby LogSnag