Skip to content

Instantly share code, notes, and snippets.

@ncarlier
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save ncarlier/2dc92a9a2783e654ea48 to your computer and use it in GitHub Desktop.

Select an option

Save ncarlier/2dc92a9a2783e654ea48 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = os.getenv('APP_PORT', 8080)
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("Hello World !")
return
try:
server = HTTPServer(('', int(PORT_NUMBER)), myHandler)
print 'myHandler started httpserver on port ' , PORT_NUMBER
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment