A Simple Server to Capture Single Short Requests

Craig Edgmon cedgmon at shaw.ca
Tue Mar 2 18:47:07 CET 2004

I am working through Steve Holdens book on Python Web Development and
this may seem like an obvious question, but my error states that
MyRequestHandler is not defined. Any ideas on this?

import SocketServer

class MyRequestHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        print "_____________________________"
        print "From: ", self.client_address
        print "_____________________________"
        input = self.request.recv(10240)
        print input.replace('\r', '')
        print "_____________________________"
        self.request.send("HTTP/1.1 200 OK\r\n")
        self.request.send("Content-Type: text/html\n\n")
    myServer = SocketServer.TCPServer(('', 8080), MyRequestHandler)

More information about the Python-list mailing list