Mercurial > hg > index.fcgi > www > www-1
view pics2/pics_test_server.py @ 126:a00f9d3beb9b
myrss2: update FEEDS for aeon.co
author | paulo |
---|---|
date | Fri, 01 Oct 2021 23:32:22 -0700 |
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()