#!/usr/bin/python # dummyhttpd - start a HTTP daemon and print what the client sends import SocketServer # or use BaseHTTPServer, SimpleHTTPServer, CGIHTTPServer def adr_str(adr): return "%s:%d" % adr class RequestHandler(SocketServer.BaseRequestHandler): def handle(self): print "client access from %s" % adr_str(self.client_address) print self.request.recv(10000) self.request.send("Content-Type: text/plain\n" "Server: dymmyhttpd/1.0.0\n" "\n...\n") self.request.close() adr = ('127.0.0.1', 8001) print "Please contact me at " % adr_str(adr) server = SocketServer.TCPServer(adr, RequestHandler) server.serve_forever() server.server_close()