simple httpserver


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.