Posted By

manatlan on 09/10/09


Tagged

http server python web


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

nerdfiles
gartenstuhl


simple httpserver


 / Published in: Python
 

  1. from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
  2.  
  3. class MyServer(BaseHTTPRequestHandler):
  4. def do_GET(self):
  5. self.send_response(200, 'OK')
  6. self.send_header('Content-type', 'text/html')
  7. self.end_headers()
  8. self.wfile.write( "hello" )
  9.  
  10. @staticmethod
  11. def serve_forever(port):
  12. HTTPServer(('', port), MyServer).serve_forever()
  13.  
  14. if __name__ == "__main__":
  15. MyServer.serve_forever(8080)

Report this snippet  

You need to login to post a comment.