Skip to content

Instantly share code, notes, and snippets.

@bmsleight
Created January 28, 2016 22:58
Show Gist options
  • Save bmsleight/bc34254eed0ee458738e to your computer and use it in GitHub Desktop.
Save bmsleight/bc34254eed0ee458738e to your computer and use it in GitHub Desktop.
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
from os import environ
def test(HandlerClass=SimpleHTTPRequestHandler,
ServerClass=BaseHTTPServer.HTTPServer):
protocol = "HTTP/1.0"
host = environ.get('OPENSHIFT_PYTHON_IP')
port = int(environ.get('OPENSHIFT_PYTHON_PORT'))
server_address = (host, port)
HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
if __name__ == "__main__":
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment