Simplehttpserver And Socketserver
I have created a 'handler' python script as follows: import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketSer
Solution 1:
You can inherit SimpleHTTPServer.SimpleHTTPRequestHandler
like this:
classMyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
defdo_GET(self):
# Your code hereprint"Client requested:", self.command, self.path
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
PORT = 8000
httpd = SocketServer.TCPServer(("", PORT), MyHandler)
print"Serving at port:", PORT
httpd.serve_forever()
That will print in console:
Client requested GET /?var=data/
Check documentation on SimpleHTTPRequestHandler and BaseHTTPRequestHandler for more information.
Post a Comment for "Simplehttpserver And Socketserver"