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