Mercurial > hg > index.fcgi > www > www-1
annotate pics2/pics_test_server.py @ 56:0249782e231e
pics2: add np_keys and selected thumbnail anchoring
author | paulo |
---|---|
date | Tue, 10 Sep 2013 01:04:24 -0700 |
parents | f5c2934a1e3f |
children | b7966ae653f2 |
rev | line source |
---|---|
paulo@56 | 1 import os |
paulo@56 | 2 import sys |
paulo@56 | 3 import signal |
paulo@56 | 4 |
paulo@56 | 5 import cherrypy |
paulo@56 | 6 from cherrypy import wsgiserver |
paulo@52 | 7 |
paulo@52 | 8 import pics_app |
paulo@52 | 9 |
paulo@52 | 10 |
paulo@56 | 11 def sighandler(signum, frame): |
paulo@56 | 12 sys.stderr.write("Caught signal: %s \n" % signum) |
paulo@56 | 13 server.stop() |
paulo@56 | 14 |
paulo@56 | 15 |
paulo@56 | 16 class FileServerRoot: |
paulo@56 | 17 def default(self, *args): |
paulo@56 | 18 if len(args) == 0: |
paulo@56 | 19 raise cherrypy.HTTPError(404) |
paulo@56 | 20 |
paulo@56 | 21 filepath = os.path.abspath(os.path.join(*args)) |
paulo@56 | 22 return cherrypy.lib.static.serve_file(filepath) |
paulo@56 | 23 |
paulo@56 | 24 default.exposed = True |
paulo@52 | 25 |
paulo@52 | 26 |
paulo@52 | 27 if __name__ == "__main__": |
paulo@56 | 28 fileServerApp = cherrypy.Application(FileServerRoot()) |
paulo@56 | 29 dispatcher = wsgiserver.WSGIPathInfoDispatcher({ |
paulo@56 | 30 "/pics.fcgi": pics_app.app, |
paulo@56 | 31 "": fileServerApp, |
paulo@56 | 32 }) |
paulo@56 | 33 server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8000), dispatcher) |
paulo@56 | 34 |
paulo@56 | 35 signal.signal(signal.SIGINT, sighandler) |
paulo@56 | 36 signal.signal(signal.SIGTERM, sighandler) |
paulo@56 | 37 |
paulo@56 | 38 server.start() |