From: R. Steve McKown Date: Tue, 15 Dec 2009 02:11:29 +0000 (-0700) Subject: A mini web server that serves the contents of 'out'. X-Git-Url: https://oss.titaniummirror.com/gitweb?p=oss-web.git;a=commitdiff_plain;h=dc48a77db26b141b0f2e9e30b6db817ec0e31a5f A mini web server that serves the contents of 'out'. --- diff --git a/serve.py b/serve.py new file mode 100755 index 0000000..a49e8d9 --- /dev/null +++ b/serve.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +import os + +class Server(): + def serve(self, dir, port): + """ serve the deploy directory with an very simple, cgi + capable web server on 0.0.0.0:. + """ + from BaseHTTPServer import HTTPServer + from CGIHTTPServer import CGIHTTPRequestHandler + os.chdir(dir) + httpd = HTTPServer(('', int(port)), CGIHTTPRequestHandler) + sa = httpd.socket.getsockname() + print "Serving HTTP on", sa[0], "port", sa[1], "..." + try: + httpd.serve_forever() + except KeyboardInterrupt: + pass + +if __name__ == "__main__": + server = Server() + server.serve('out', 8000)