DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Simplest Httpserver With Python
responding "hello" at http://localhost:8080
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200, 'OK')
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write( "hello" )
@staticmethod
def serve_forever(port):
HTTPServer(('', port), MyServer).serve_forever()
if __name__ == "__main__":
MyServer.serve_forever(8080)




