예제 #1
0
 def __init__(self, spotty):
     self.__root = Root(spotty)
     log = cherrypy.log
     log.screen = True
     cherrypy.config.update({
         'server.socket_host': '127.0.0.1',
         'server.socket_port': PROXY_PORT
     })
     self.__server = cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)
     threading.Thread.__init__(self)
예제 #2
0
 def __init__(self, spotty):
     self.__root = Root(spotty)
     cherrypy.config.update({
         'engine.timeout_monitor.frequency': 5,
         'server.shutdown_timeout': 1,
         'engine.autoreload.on': False,
         'log.screen': False,
     })
     self.__server = cherrypy.server.httpserver = CPHTTPServer(
         cherrypy.server)
     threading.Thread.__init__(self)
예제 #3
0
 def __init__(self, spotty):
     self.__root = Root(spotty)
     log = cherrypy.log
     log.access_file = ''
     log.error_file = ''
     log.screen = False
     cherrypy.config.update({
         'server.socket_host': '0.0.0.0',
         'server.socket_port': PROXY_PORT,
         'engine.timeout_monitor.frequency': 5,
         'server.shutdown_timeout': 1
     })
     self.__server = cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)
     threading.Thread.__init__(self)
예제 #4
0
def main(config: 'Configuration file'):  # noqa: F722
    try:
        cfg = configure(config)
        renderer.init()
        cherrypy.log('START', 'INFO')
        cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)
        cherrypy.tree.mount(root.Root(cfg), root.path, root.config)
        cherrypy.tree.mount(packs.Packs(cfg), packs.path, packs.config)
        cherrypy.tree.mount(simple.Simple(cfg), simple.path, simple.config)
        cherrypy.engine.signals.subscribe()
        cherrypy.engine.start()
        cherrypy.engine.block()
    except Exception as ex:
        cherrypy.log(str(ex), 'ERROR', traceback=PYPP_DEBUG)
        sys.exit(ex)
    finally:
        cherrypy.log('STOP', 'INFO')
예제 #5
0
    def __init__(self, param):
        self.param = param
        self.port = WwUtil.getFreeSocketPort("tcp")
        self.root = Root()

        from cherrypy._cpnative_server import CPHTTPServer
        cherrypy.server.socket_host = "127.0.0.1"
        cherrypy.server.socket_port = self.port
        cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)

        cfgDict = dict()
        cfgDict["/"] = {
            "tools.staticdir.root": self.param.wwwDir,
        }
        cfgDict["/index.html"] = {}
        cfgDict["/common"] = {
            "tools.staticdir.on": True,
            "tools.staticdir.dir": "./common",
        }
        cfgDict["/api"] = {}
        for fn in os.listdir(os.path.join(self.param.wwwDir, "pages")):
            cfgDict["/pages/%s/%s.html" % (fn)] = {}
            if os.path.exists(os.path.join(self.param.wwwDir, "pages", "css")):
                cfgDict["/pages/%s/css" % (fn)] = {
                    "tools.staticdir.on": True,
                    "tools.staticdir.dir": "./pages/%s/css" % (fn),
                }
            if os.path.exists(
                    os.path.join(self.param.wwwDir, "pages", "images")):
                cfgDict["/pages/%s/images" % (fn)] = {
                    "tools.staticdir.on": True,
                    "tools.staticdir.dir": "./pages/%s/images" % (fn),
                }
            if os.path.exists(os.path.join(self.param.wwwDir, "pages", "js")):
                cfgDict["/pages/%s/js" % (fn)] = {
                    "tools.staticdir.on": True,
                    "tools.staticdir.dir": "./pages/%s/js" % (fn),
                }
            cfgDict["/api/"] = {}
        cherrypy.tree.mount(self.root, config=cfgDict)

        cherrypy.engine.start()
예제 #6
0
def run(env, native):
    """
    Start listening and serving applications on the address and port defining in
    the configuration.
    """
    create_app()

    conf = '/etc/FirstCherryPy.conf'
    if not os.path.isfile(conf):
        conf = os.path.normpath(os.path.join(os.path.dirname(__file__),
                                             '..', 'conf',
                                             'FirstCherryPy.conf'))
    cherrypy.config.update(conf)

    if env in ['production', 'staging']:
        cherrypy.config.update({'environment': env})

    if native:
        cherrypy.server = CPHTTPServer(cherrypy.server)
    cherrypy.engine.signals.subscribe()
    cherrypy.engine.start()
    cherrypy.engine.block()
예제 #7
0
import cherrypy

class Root(object):
    @cherrypy.expose
    def index(self):
        return "Hello World!"

if __name__ == '__main__':
    from cherrypy._cpnative_server import CPHTTPServer
    cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)

    cherrypy.quickstart(Root(), '/')