Skip to content Skip to sidebar Skip to footer

Python's Basehttpserver Returns Junky Responses

I use Python's BaseHTTPServer and implement the following very simple BaseHTTPRequestHandler: class WorkerHandler(BaseHTTPRequestHandler): def do_GET(self): self.wfile

Solution 1:

Finally succeeded fixing it myself. Sharing with you:

classWorkerHandler(BaseHTTPRequestHandler):defdo_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write('{"status" : "ready"}')

Swapped the send_response and wfile.write. Also added end_headers after send_response

Post a Comment for "Python's Basehttpserver Returns Junky Responses"