I want to extend SimpleHTTPRequestHandler and override the default behavior of do_GET(). I am returning a string from my custom handler but the client doesn’t receive the response.
Here is my handler class:
DUMMY_RESPONSE = """Content-type: text/html
<html>
<head>
<title>Python Test</title>
</head>
<body>
Test page...success.
</body>
</html>
"""
class MyHandler(CGIHTTPRequestHandler):
def __init__(self,req,client_addr,server):
CGIHTTPRequestHandler.__init__(self,req,client_addr,server)
def do_GET(self):
return DUMMY_RESPONSE
What must I change to make this work correctly?
Something like (untested code):