Skip to content

Instantly share code, notes, and snippets.

@jeffgca
Forked from anonymous/gist:3131316
Created July 17, 2012 19:07
Show Gist options
  • Save jeffgca/3131318 to your computer and use it in GitHub Desktop.
Save jeffgca/3131318 to your computer and use it in GitHub Desktop.
Webapp Servage
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-p",
"--port",
dest="port",
help="port to listen on.",
default=8000
)
(options, args) = parser.parse_args()
if __name__ == '__main__':
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
# add the .webapp content type
Handler.extensions_map['.webapp'] = 'application/x-web-app-manifest+json'
httpd = SocketServer.TCPServer(("", int(options.port)), Handler)
print "Serving at port %d" % int(options.port)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment