本文整理汇总了Python中cherrypy.wsgiserver.CherryPyWSGIServer方法的典型用法代码示例。如果您正苦于以下问题:Python wsgiserver.CherryPyWSGIServer方法的具体用法?Python wsgiserver.CherryPyWSGIServer怎么用?Python wsgiserver.CherryPyWSGIServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cherrypy.wsgiserver
的用法示例。
在下文中一共展示了wsgiserver.CherryPyWSGIServer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
def run(self, handler):
try:
# First try to use the new version
from cheroot.ssl.pyopenssl import pyOpenSSLAdapter
from cheroot import wsgi
server = wsgi.Server((self.host, self.port), handler, request_queue_size=32)
except Exception:
from cherrypy.wsgiserver.ssl_pyopenssl import pyOpenSSLAdapter
from cherrypy import wsgiserver
server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler, request_queue_size=32)
self.srv = server
# If cert variable is has a valid path, SSL will be used
# You can set it to None to disable SSL
server.ssl_adapter = pyOpenSSLAdapter(Config.REST_SSL_CERTFILE,
Config.REST_SSL_KEYFILE,
Config.REST_SSL_CA_CERTS)
try:
server.start()
finally:
server.stop()
示例2: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
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()
示例3: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
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()
示例4: main
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
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()
示例5: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
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()
示例6: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
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()
示例7: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
def run(self, handler):
from cherrypy import wsgiserver
server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler)
server.start()
示例8: run
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
def run(self, handler): # pragma: no cover
from cherrypy import wsgiserver
server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler)
server.start()
示例9: run_on_cherrypy_for_production
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
def run_on_cherrypy_for_production():
'''
run on cherrypy without auto_reload option
'''
from cherrypy import wsgiserver
dispatch = wsgiserver.WSGIPathInfoDispatcher({'/': app})
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', web_conf.PORT), dispatch)
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例10: get_server
# 需要导入模块: from cherrypy import wsgiserver [as 别名]
# 或者: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
def get_server(address, port, application):
def _serve(server):
server.start()
server = wsgiserver.CherryPyWSGIServer((address, int(port)), application)
t = threading.Thread(target=_serve, args=(server,))
t.daemon = True
return (t, server)