Advertisement
Guest User

Untitled

a guest
Jan 12th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import time
  4. import BaseHTTPServer
  5.  
  6.  
  7. HOST_NAME = 'localhost'
  8. PORT_NUMBER = 9001
  9.  
  10.  
  11. class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  12.     def do_GET(s):
  13.         """Respond to a GET request."""
  14.         s.send_response(200)
  15.         s.end_headers()
  16.         s.wfile.write("Done")
  17.  
  18. if __name__ == '__main__':
  19.     server_class = BaseHTTPServer.HTTPServer
  20.     httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
  21.     print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
  22.     try:
  23.         httpd.serve_forever()
  24.     except KeyboardInterrupt:
  25.         pass
  26.     httpd.server_close()
  27.     print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement