A Simple Server to Capture Single Short Requests

Discussion in 'Python' started by Craig Edgmon, Mar 2, 2004.

  1. Craig Edgmon

    Craig Edgmon Guest

    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")
    self.request.send("<HTML><BODY><H2>Hello!</H2></BODY></HTML>")
    self.request.close()

    myServer = SocketServer.TCPServer(('', 8080), MyRequestHandler)
    myServer.handle_request()
     
    Craig Edgmon, Mar 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Arámburu

    web requests and mobile requests

    Fernando Arámburu, Apr 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    462
    Joerg Jooss
    Apr 8, 2005
  2. David Geering

    longs, long longs, short short long ints . . . huh?!

    David Geering, Jan 8, 2007, in forum: C Programming
    Replies:
    15
    Views:
    581
    Keith Thompson
    Jan 11, 2007
  3. Replies:
    4
    Views:
    857
    Kaz Kylheku
    Oct 17, 2006
  4. Ioannis Vranos

    unsigned short, short literals

    Ioannis Vranos, Mar 4, 2008, in forum: C Programming
    Replies:
    5
    Views:
    717
    Eric Sosman
    Mar 5, 2008
  5. Andre
    Replies:
    5
    Views:
    556
    Keith Thompson
    Jul 17, 2012
Loading...

Share This Page