Mercurial > hg > index.fcgi > www > www-1
view index_test_server.py @ 86:a0fdf2cf1d53
add "selection" feature to life_calendar; fix minor typos in deer_crash
author | paulo |
---|---|
date | Sat, 17 Sep 2016 00:11:41 -0700 |
parents | 50de1845520f |
children |
line source
1 import os
2 import sys
3 import signal
5 import cherrypy
6 from cherrypy import wsgiserver
8 import index_app
11 def sighandler(signum, frame):
12 sys.stderr.write("Caught signal: %s \n" % signum)
13 server.stop()
16 class FileServerRoot:
17 def default(self, *args):
18 if len(args) == 0:
19 raise cherrypy.HTTPError(404)
21 filepath = os.path.abspath(os.path.join(*args))
22 return cherrypy.lib.static.serve_file(filepath)
24 default.exposed = True
27 if __name__ == "__main__":
28 fileServerApp = cherrypy.Application(FileServerRoot())
29 dispatcher = wsgiserver.WSGIPathInfoDispatcher({
30 "/index.fcgi": index_app.app,
31 "": fileServerApp,
32 })
33 server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8000), dispatcher)
35 signal.signal(signal.SIGINT, sighandler)
36 signal.signal(signal.SIGTERM, sighandler)
38 server.start()