Mercurial > hg > index.fcgi > www > www-1
comparison index_test_server.py @ 57:b7966ae653f2
pics2: add support for .webm files; add pics.fcgi and index.css
author | paulo |
---|---|
date | Tue, 14 Jan 2014 23:44:24 -0800 |
parents | 50de1845520f |
children |
comparison
equal
deleted
inserted
replaced
0:8994de8d3829 | 1:410003c9ad1c |
---|---|
1 import wsgiref.simple_server | 1 import os |
2 import SocketServer | 2 import sys |
3 import signal | |
4 | |
5 import cherrypy | |
6 from cherrypy import wsgiserver | |
3 | 7 |
4 import index_app | 8 import index_app |
5 | 9 |
6 | 10 |
7 class ThreadingWSGIServer(SocketServer.ThreadingMixIn, wsgiref.simple_server.WSGIServer): | 11 def sighandler(signum, frame): |
8 pass | 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 | |
9 | 25 |
10 | 26 |
11 if __name__ == "__main__": | 27 if __name__ == "__main__": |
12 httpd = ThreadingWSGIServer(('', 8000), wsgiref.simple_server.WSGIRequestHandler) | 28 fileServerApp = cherrypy.Application(FileServerRoot()) |
13 httpd.set_app(index_app.app) | 29 dispatcher = wsgiserver.WSGIPathInfoDispatcher({ |
14 httpd.serve_forever() | 30 "/index.fcgi": index_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() |