comparison laterlinks2/test_server.py @ 68:66a232bae83c

myrss: add commented out debug logging code
author paulo
date Thu, 11 Jun 2015 21:25:03 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:89fa59fe364d
1 import os
2 import sys
3 import signal
4
5 import cherrypy
6 from cherrypy import wsgiserver
7
8 import laterlinks_app
9
10
11 def sighandler(signum, frame):
12 sys.stderr.write("Caught signal: %s \n" % signum)
13 server.stop()
14
15
16 class FileServerRoot:
17 def default(self, *args):
18 if len(args) == 0:
19 raise cherrypy.HTTPError(404)
20
21 filepath = os.path.abspath(os.path.join(*args))
22 return cherrypy.lib.static.serve_file(filepath)
23
24 default.exposed = True
25
26
27 if __name__ == "__main__":
28 fileServerApp = cherrypy.Application(FileServerRoot())
29 dispatcher = wsgiserver.WSGIPathInfoDispatcher({
30 "/index.fcgi": laterlinks_app.app,
31 "": fileServerApp,
32 })
33 server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8000), dispatcher)
34
35 signal.signal(signal.SIGINT, sighandler)
36 signal.signal(signal.SIGTERM, sighandler)
37
38 server.start()