# a very simple python3 HTTP responder # which hands chunked encoded packets import sys from http.server import BaseHTTPRequestHandler, HTTPServer def chunk_data(data, chunk_size): dl = len(data) ret = "" for i in range(dl // chunk_size): ret += "%s\r\n" % (hex(chunk_size)[2:]) ret += "%s\r\n" % (data[i * chunk_size : (i + 1) * chunk_size]) if len(data) % chunk_size != 0: ret += "%s\r\n" % (hex(len(data) % chunk_size)[2:]) ret += "%s\r\n" % (data[-(len(data) % chunk_size):]) ret += "0\r\n\r\n" return ret class responderHTTPServerRequestHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.send_header('Transfer-Encoding', 'chunked') self.end_headers() result="\n\n

This works!

\n\n" #self.wfile.write(bytes(result, "utf-8")) self.wfile.write(bytes(chunk_data(result, 5), "utf-8")) def do_HEAD(self): self.do_GET() def main(): httpd = HTTPServer(('127.0.0.1', 6080), responderHTTPServerRequestHandler) httpd.serve_forever() main()