Python cherrypy 模块,quickstart() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用cherrypy.quickstart()

项目:sqlalchemy-media    作者:pylover    | 项目源码 | 文件源码
def main():

    if not path.exists(TEMP_PATH):
        mkdir(TEMP_PATH)

    StoreManager.register(
        'fs',
        functools.partial(FileSystemStore, TEMP_PATH, 'http://localhost:8080/avatars'),
        default=True
    )

    conf = {
        '/': {
            'tools.sessions.on': True,
            'tools.staticdir.root': WORKING_DIR
        },
        '/avatars': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': TEMP_PATH
        }
    }

    cherrypy.quickstart(Root(), config=conf)
项目:pub1ic_POC    作者:i1ikey0u    | 项目源码 | 文件源码
def main():
  find_rop_gadgets('libc.so')
  with open('exploit.mp4', 'wb') as tmp:
    tmp.write(exploit_mp4())
  cherrypy.quickstart(ExploitServer())
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def run(self):
        conf = { '/': {}}
        cherrypy.quickstart(self.__root, '/', conf)
项目:fitbit-googlefit    作者:praveendath92    | 项目源码 | 文件源码
def browser_authorize(self):
        """
        Open a browser to the authorization url and spool up a CherryPy
        server to accept the response
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Open the web browser in a new thread for command-line browser support
        threading.Timer(1, webbrowser.open, args=(url,)).start()
        cherrypy.quickstart(self)
项目:bookrat    作者:DexterLB    | 项目源码 | 文件源码
def main(db):
    conf = {
        '/': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(
                os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
                'web'
            )
        },
    }
    cherrypy.quickstart(Server(db), '/', conf)
项目:MMM-fitbit    作者:SVendittelli    | 项目源码 | 文件源码
def browser_authorize(self):
        """
        Open a browser to the authorization url and spool up a CherryPy
        server to accept the response
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Open the web browser in a new thread for command-line browser support
        threading.Timer(1, webbrowser.open, args=(url,)).start()
        cherrypy.quickstart(self)
项目:Fitbit    作者:jaromirsalamon    | 项目源码 | 文件源码
def browser_authorize(self):
        """
        Open a browser to the authorization url and spool up a CherryPy
        server to accept the response
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Open the web browser in a new thread for command-line browser support
        threading.Timer(1, webbrowser.open, args=(url,)).start()
        cherrypy.config.update({'server.socket_host': '127.0.0.1','server.socket_port': 8000})
        cherrypy.quickstart(self)
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def run():
    # user anonymity is achieved in the laziest possible way: a literal user
    # named anonymous. may god have mercy on my soul.
    _c = sqlite3.connect(dbname)
    try:
        db.anon = db.user_resolve(_c, "anonymous")
        if not db.anon:
            db.anon = db.user_register(
                _c, "anonymous",  # this is the hash for "anon"
                "5430eeed859cad61d925097ec4f53246"
                "1ccf1ab6b9802b09a313be1478a4d614")
    finally:
        _c.close()
    cherrypy.quickstart(API(), "/api", API_CONFIG)
项目:autosub-bootstrapbill    作者:BenjV    | 项目源码 | 文件源码
def serve(path=None, port=8080):
    if profile is None or pstats is None:
        msg = ('Your installation of Python does not have a profile module. '
               "If you're on Debian, try "
               '`sudo apt-get install python-profiler`. '
               'See http://www.cherrypy.org/wiki/ProfilingOnDebian '
               'for details.')
        warnings.warn(msg)

    cherrypy.config.update({'server.socket_port': int(port),
                            'server.thread_pool': 10,
                            'environment': 'production',
                            })
    cherrypy.quickstart(Profiler(path))
项目:autosub-bootstrapbill    作者:BenjV    | 项目源码 | 文件源码
def serve(path=localFile, port=8080, root=None):
    if coverage is None:
        raise ImportError('The coverage module could not be imported.')
    from coverage import coverage
    cov = coverage(data_file=path)
    cov.load()

    import cherrypy
    cherrypy.config.update({'server.socket_port': int(port),
                            'server.thread_pool': 10,
                            'environment': 'production',
                            })
    cherrypy.quickstart(CoverStats(cov, root))
项目:deel    作者:uei    | 项目源码 | 文件源码
def StartAgent(trainer=None,port=8765):
    global workout
    workout = trainer
    cherrypy.config.update({'server.socket_port': port})
    WebSocketPlugin(cherrypy.engine).subscribe()
    cherrypy.tools.websocket = WebSocketTool()
    cherrypy.config.update({'engine.autoreload.on': False})
    config = {'/ws': {'tools.websocket.on': True,
                      'tools.websocket.handler_cls': AgentServer}}
    cherrypy.quickstart(Root(), '/', config)
项目:health    作者:cedricbonhomme    | 项目源码 | 文件源码
def browser_authorize(self):
        """
        Open a browser to the authorization url and spool up a CherryPy
        server to accept the response
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Open the web browser in a new thread for command-line browser support
        threading.Timer(1, webbrowser.open, args=(url,)).start()
        cherrypy.quickstart(self)
项目:abc    作者:daemon    | 项目源码 | 文件源码
def run_server(top10k, top100k, nlp, model):
  cherrypy.config.update({
    "environment": "production",
    "log.screen": True
  })
  cherrypy.server.socket_port = 16384
  #cherrypy.server.socket_host = "0.0.0.0"
  rest_conf = {"/": {
    "request.dispatch": cherrypy.dispatch.MethodDispatcher(),
    'cors.expose.on': True
  }}
  cherrypy_cors.install()
  cherrypy.quickstart(SimplifyEndpoint(top10k, top100k, nlp, model), "/simplify", rest_conf)
项目:pytest-vts    作者:bhodorog    | 项目源码 | 文件源码
def run_cherrypy(port, root_kls=Root):
    import logging
    logging.getLogger("cherrypy").setLevel(logging.DEBUG)
    cherrypy.config.update({
        "server.socket_port": port,
        "engine.autoreload.on": False,
        "engine.timeout_monitor.on": False,
        # "log.screen": False
    })
    cherrypy.quickstart(root_kls(), "/")
项目:social-examples    作者:python-social-auth    | 项目源码 | 文件源码
def run_app(listen_address="0.0.0.0:8001"):
    host, port = listen_address.rsplit(':', 1)
    cherrypy.config.update({
        'server.socket_port': int(port),
        'server.socket_host': host,
        'tools.sessions.on': True,
        'tools.sessions.storage_type': 'ram',
        'tools.db.on': True,
        'tools.authenticate.on': True,
        'SOCIAL_AUTH_USER_MODEL': 'example.db.user.User',
        'SOCIAL_AUTH_LOGIN_URL': '/',
        'SOCIAL_AUTH_LOGIN_REDIRECT_URL': '/done',
    })
    cherrypy.config.update(SOCIAL_SETTINGS)
    cherrypy.tools.jinja2env = Environment(
        loader=FileSystemLoader(os.path.join(BASE_DIR, 'common', 'templates'))
    )
    cherrypy.tools.jinja2env.filters.update({
        'backend_name': filters.backend_name,
        'backend_class': filters.backend_class,
        'icon_name': filters.icon_name,
        'social_backends': filters.social_backends,
        'legacy_backends': filters.legacy_backends,
        'oauth_backends': filters.oauth_backends,
        'filter_backends': filters.filter_backends,
        'slice_by': filters.slice_by
    })
    cherrypy.tools.jinja2env.globals.update({
        'url': url_for
    })
    cherrypy.tools.db = SATool()
    cherrypy.tools.authenticate = cherrypy.Tool('before_handler', load_user)
    cherrypy.tools.session = cherrypy.Tool('on_end_resource', session_commit)
    cherrypy.quickstart(PSAExample())
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def serve(path=None, port=8080):
    if profile is None or pstats is None:
        msg = ("Your installation of Python does not have a profile module. "
               "If you're on Debian, try "
               "`sudo apt-get install python-profiler`. "
               "See http://www.cherrypy.org/wiki/ProfilingOnDebian "
               "for details.")
        warnings.warn(msg)

    import cherrypy
    cherrypy.config.update({'server.socket_port': int(port),
                            'server.thread_pool': 10,
                            'environment': "production",
                            })
    cherrypy.quickstart(Profiler(path))
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def serve(path=localFile, port=8080, root=None):
    if coverage is None:
        raise ImportError("The coverage module could not be imported.")
    from coverage import coverage
    cov = coverage(data_file=path)
    cov.load()

    import cherrypy
    cherrypy.config.update({'server.socket_port': int(port),
                            'server.thread_pool': 10,
                            'environment': "production",
                            })
    cherrypy.quickstart(CoverStats(cov, root))
项目:cherrypy-cors    作者:yougov    | 项目源码 | 文件源码
def run(cls):
        cherrypy_cors.install()
        config = {
            '/': {
                'cors.expose.on': True,
            },
        }
        cherrypy.quickstart(cls(), config=config)
项目:fitbit-fetch    作者:tomh05    | 项目源码 | 文件源码
def browser_authorize(self):
        """
        Open a browser to the authorization url and spool up a CherryPy
        server to accept the response
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Open the web browser in a new thread for command-line browser support
        threading.Timer(1, webbrowser.open, args=(url,)).start()
        cherrypy.quickstart(self)
项目:thermostat_ita    作者:jpnos26    | 项目源码 | 文件源码
def startWebServer():   
    host = "discover" if not( settings.exists( "web" ) ) else settings.get( "web" )[ "host" ]
    #cherrypy.server.socket_host = host if host != "discover" else get_ip_address() # use machine IP address if host = "discover"
    cherrypy.server.socket_port = 80 if not( settings.exists( "web" ) ) else settings.get( "web" )[ "port" ]

    log( LOG_LEVEL_STATE, CHILD_DEVICE_WEBSERVER, MSG_SUBTYPE_TEXT, "Starting on " + cherrypy.server.socket_host + ":" + str( cherrypy.server.socket_port ) )

    conf = {
        '/': {
            'tools.staticdir.root': os.path.abspath( os.getcwd() ),
            'tools.staticfile.root': os.path.abspath( os.getcwd() )
        },
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/css'
        },
        '/javascript': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/javascript'
        },
        '/images': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/images'
        },
        '/schedule.json': {
            'tools.staticfile.on': True,
            'tools.staticfile.filename': './thermostat_schedule.json'
        },
        '/favicon.ico': {
            'tools.staticfile.on': True,
            'tools.staticfile.filename': './web/images/favicon.ico'
        },
        '/graph': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/graph'
        }

    }

    cherrypy.config.update(
        { 'log.screen': debug,
          'log.access_file': "",
          'log.error_file': "",
          'server.thread_pool' : 10  
        }
    )

    cherrypy.quickstart ( WebInterface(), '/', conf )   


##############################################################################
#                                                                            #
#       Main                                                                 #
#                                                                            #
##############################################################################
项目:RaspberryPiThermostat    作者:scottpav    | 项目源码 | 文件源码
def startWebServer():   
    host = "discover" if not( settings.exists( "web" ) ) else settings.get( "web" )[ "host" ]
    cherrypy.server.socket_host = host if host != "discover" else get_ip_address()                              # use machine IP address if host = "discover"
    cherrypy.server.socket_port = 80 if not( settings.exists( "web" ) ) else settings.get( "web" )[ "port" ]

    log( LOG_LEVEL_STATE, CHILD_DEVICE_WEBSERVER, MSG_SUBTYPE_TEXT, "Starting on " + cherrypy.server.socket_host + ":" + str( cherrypy.server.socket_port ) )

    conf = {
        '/': {
            'tools.staticdir.root': os.path.abspath( os.getcwd() ),
            'tools.staticfile.root': os.path.abspath( os.getcwd() )
        },
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/css'
        },
        '/javascript': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/javascript'
        },
        '/images': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './web/images'
        },
        '/schedule.json': {
            'tools.staticfile.on': True,
            'tools.staticfile.filename': './thermostat_schedule.json'
        },
        '/favicon.ico': {
            'tools.staticfile.on': True,
            'tools.staticfile.filename': './web/images/favicon.ico'
        }

    }

    cherrypy.config.update(
        { 'log.screen': debug,
          'log.access_file': "",
          'log.error_file': ""
        }
    )

    cherrypy.quickstart ( WebInterface(), '/', conf )   


##############################################################################
#                                                                            #
#       Main                                                                 #
#                                                                            #
##############################################################################