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:

class WorkerHandler(BaseHTTPRequestHandler):

    def do_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"