view pics2/pics_test_server.py @ 64:33e8f29e0941

update myrss/FEEDS
author paulo
date Wed, 24 Sep 2014 14:15:14 -0600
parents 0249782e231e
children
line source
1 import os
2 import sys
3 import signal
5 import cherrypy
6 from cherrypy import wsgiserver
8 import pics_app
11 def sighandler(signum, frame):
12 sys.stderr.write("Caught signal: %s \n" % signum)
13 server.stop()
16 MIMETYPE = {
17 ".webm": "video/webm",
18 }
21 class FileServerRoot:
22 def default(self, *args):
23 if len(args) == 0:
24 raise cherrypy.HTTPError(404)
26 filepath = os.path.abspath(os.path.join(*args))
27 ext = os.path.splitext(filepath)[1]
28 return cherrypy.lib.static.serve_file(filepath, content_type=MIMETYPE.get(ext))
30 default.exposed = True
33 if __name__ == "__main__":
34 fileServerApp = cherrypy.Application(FileServerRoot())
35 dispatcher = wsgiserver.WSGIPathInfoDispatcher({
36 "/pics.fcgi": pics_app.app,
37 "": fileServerApp,
38 })
39 server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8000), dispatcher)
41 signal.signal(signal.SIGINT, sighandler)
42 signal.signal(signal.SIGTERM, sighandler)
44 server.start()