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. Advertisements

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. =?Utf-8?B?QWRyaWphbiBKb3NpYw==?=

    catching all requests with a single page

    =?Utf-8?B?QWRyaWphbiBKb3NpYw==?=, Feb 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    492
    bruce barker
    Feb 6, 2004
  2. Fernando Arámburu

    web requests and mobile requests

    Fernando Arámburu, Apr 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    634
    Joerg Jooss
    Apr 8, 2005
  3. Max
    Replies:
    7
    Views:
    9,394
  4. David Geering

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

    David Geering, Jan 8, 2007, in forum: C Programming
    Replies:
    15
    Views:
    830
    Keith Thompson
    Jan 11, 2007
  5. Replies:
    4
    Views:
    1,104
    Kaz Kylheku
    Oct 17, 2006
  6. Ioannis Vranos

    unsigned short, short literals

    Ioannis Vranos, Mar 4, 2008, in forum: C Programming
    Replies:
    5
    Views:
    943
    Eric Sosman
    Mar 5, 2008
  7. ³É¶¼ÆßÖÐ2002¼¶7°à_´ó¼Ò¶¼ÊÇÌì²Å¡«

    i have configured proxy but fiddler can't capture python's network requests

    ³É¶¼ÆßÖÐ2002¼¶7°à_´ó¼Ò¶¼ÊÇÌì²Å¡«, Jul 4, 2011, in forum: Python
    Replies:
    1
    Views:
    729
    Chris Angelico
    Jul 4, 2011
  8. Andre
    Replies:
    5
    Views:
    792
    Keith Thompson
    Jul 17, 2012
Loading...