Monday, May 14, 2012

All the cheat-sheets

http://www.addedbytes.com/cheat-sheets/

Simple python web server, RequestHandler

This is a simple python script to create a python HTTPServer handle GET request


#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        #print self.headers
        print self.headers.getheader('Content-Length')
        self.wfile.write('HELLO!!!')
server = HTTPServer(('', 58621), Handler)
server.serve_forever()


-EOF-