paulo@60: import os paulo@60: import sys paulo@60: import signal paulo@60: paulo@60: import cherrypy paulo@60: from cherrypy import wsgiserver paulo@60: paulo@60: import laterlinks_app paulo@60: paulo@60: paulo@60: def sighandler(signum, frame): paulo@60: sys.stderr.write("Caught signal: %s \n" % signum) paulo@60: server.stop() paulo@60: paulo@60: paulo@60: class FileServerRoot: paulo@60: def default(self, *args): paulo@60: if len(args) == 0: paulo@60: raise cherrypy.HTTPError(404) paulo@60: paulo@60: filepath = os.path.abspath(os.path.join(*args)) paulo@60: return cherrypy.lib.static.serve_file(filepath) paulo@60: paulo@60: default.exposed = True paulo@60: paulo@60: paulo@60: if __name__ == "__main__": paulo@60: fileServerApp = cherrypy.Application(FileServerRoot()) paulo@60: dispatcher = wsgiserver.WSGIPathInfoDispatcher({ paulo@60: "/index.fcgi": laterlinks_app.app, paulo@60: "": fileServerApp, paulo@60: }) paulo@60: server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8000), dispatcher) paulo@60: paulo@60: signal.signal(signal.SIGINT, sighandler) paulo@60: signal.signal(signal.SIGTERM, sighandler) paulo@60: paulo@60: server.start()