我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用cherrypy.wsgiserver.CherryPyWSGIServer()。
def run(self, handler): # pragma: no cover from cherrypy import wsgiserver self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler certfile = self.options.get('certfile') if certfile: del self.options['certfile'] keyfile = self.options.get('keyfile') if keyfile: del self.options['keyfile'] server = wsgiserver.CherryPyWSGIServer(**self.options) if certfile: server.ssl_certificate = certfile if keyfile: server.ssl_private_key = keyfile try: server.start() finally: server.stop()
def main(): server_type = "werkzeug" if not config.debug_mode: server_type = "cherrypy" if config.web_server_type: server_type = config.web_server_type assert server_type in ("werkzeug", "cherrypy"), "Only werkzeug and cherrypy supported" if server_type == "werkzeug": assert config.debug_mode, "Refusing to use werkzeug outside of debug mode" app.run(config.web_host, config.web_port, debug=True, use_reloader=False, use_debugger=True, threaded=True) elif server_type == "cherrypy": dispatcher = wsgiserver.WSGIPathInfoDispatcher({"/": app}) web_server = wsgiserver.CherryPyWSGIServer((config.web_host, config.web_port), dispatcher, server_name=config.web_public_host) web_server.start()
def cherrypy(app, address, **options): from cherrypy import wsgiserver server = wsgiserver.CherryPyWSGIServer(address, app) server.start()
def rocket(app, address, **options): from gluon.rocket import CherryPyWSGIServer server = CherryPyWSGIServer(address, app) server.start()
def rocket_with_repoze_profiler(app, address, **options): from gluon.rocket import CherryPyWSGIServer from repoze.profile.profiler import AccumulatingProfileMiddleware from gluon.settings import global_settings global_settings.web2py_crontype = 'none' wrapped = AccumulatingProfileMiddleware( app, log_filename='wsgi.prof', discard_first_request=True, flush_at_shutdown=True, path='/__profile__' ) server = CherryPyWSGIServer(address, wrapped) server.start()
def run(self, server_handler): """ Overrides super to setup Cherry py with ssl and start the server. :param server_handler: originating server type :type server_handler: """ server = wsgiserver.CherryPyWSGIServer((self.host, self.port), server_handler) # Uses the following github page's recommendation for setting up the cert: # https://github.com/nickbabcock/bottle-ssl server.ssl_adapter = ssl_builtin.BuiltinSSLAdapter(conf_obj['ssl']['cacert_pem_path'], conf_obj['ssl']['privkey_pem_path']) try: server.start() finally: server.stop()
def run(self, handler): # pragma: no cover from cherrypy import wsgiserver server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler) try: server.start() finally: server.stop()
def run(self, handler): server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler) server.ssl_adapter = SecuredSSLServer(ssl_cert, ssl_key) try: server.start() finally: server.stop()
def run(self, handler): # pragma: no cover from cherrypy import wsgiserver server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler) server.start()