本文整理汇总了Python中eventlet.wsgi.server方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.server方法的具体用法?Python wsgi.server怎么用?Python wsgi.server使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet.wsgi
的用法示例。
在下文中一共展示了wsgi.server方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: urlparts
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def urlparts(self):
''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
The tuple contains (scheme, host, path, query_string and fragment),
but the fragment is always empty because it is not visible to the
server. '''
env = self.environ
http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http')
host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
if not host:
# HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
host = env.get('SERVER_NAME', '127.0.0.1')
port = env.get('SERVER_PORT')
if port and port != ('80' if http == 'http' else '443'):
host += ':' + port
path = urlquote(self.fullpath)
return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '')
示例2: run
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [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: urlparts
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def urlparts(self):
''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
The tuple contains (scheme, host, path, query_string and fragment),
but the fragment is always empty because it is not visible to the
server. '''
env = self.environ
http = env.get('wsgi.url_scheme', 'http')
host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
if not host:
# HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
host = env.get('SERVER_NAME', '127.0.0.1')
port = env.get('SERVER_PORT')
if port and port != ('80' if http == 'http' else '443'):
host += ':' + port
path = urlquote(self.fullpath)
return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '')
示例4: _cli_parse
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def _cli_parse(args): # pragma: no coverage
from argparse import ArgumentParser
parser = ArgumentParser(prog=args[0], usage="%(prog)s [options] package.module:app")
opt = parser.add_argument
opt("--version", action="store_true", help="show version number.")
opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.")
opt("-s", "--server", default='wsgiref', help="use SERVER as backend.")
opt("-p", "--plugin", action="append", help="install additional plugin/s.")
opt("-c", "--conf", action="append", metavar="FILE",
help="load config values from FILE.")
opt("-C", "--param", action="append", metavar="NAME=VALUE",
help="override config values.")
opt("--debug", action="store_true", help="start server in debug mode.")
opt("--reload", action="store_true", help="auto-reload on file changes.")
opt('app', help='WSGI app entry point.', nargs='?')
cli_args = parser.parse_args(args[1:])
return cli_args, parser
示例5: urlparts
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def urlparts(self):
""" The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
The tuple contains (scheme, host, path, query_string and fragment),
but the fragment is always empty because it is not visible to the
server. """
env = self.environ
http = env.get('HTTP_X_FORWARDED_PROTO') \
or env.get('wsgi.url_scheme', 'http')
host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')
if not host:
# HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients.
host = env.get('SERVER_NAME', '127.0.0.1')
port = env.get('SERVER_PORT')
if port and port != ('80' if http == 'http' else '443'):
host += ':' + port
path = urlquote(self.fullpath)
return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '')
示例6: run
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def run(self, handler): # pragma: no cover
from cheroot import wsgi
from cheroot.ssl import builtin
self.options['bind_addr'] = (self.host, self.port)
self.options['wsgi_app'] = handler
certfile = self.options.pop('certfile', None)
keyfile = self.options.pop('keyfile', None)
chainfile = self.options.pop('chainfile', None)
server = wsgi.Server(**self.options)
if certfile and keyfile:
server.ssl_adapter = builtin.BuiltinSSLAdapter(
certfile, keyfile, chainfile)
try:
server.start()
finally:
server.stop()
示例7: run
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [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()
示例8: main
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def main():
service.prepare_service("gapi", sys.argv)
log.info('Completed configuration file parsing...')
log.info('Completed logger initialization...')
app = api.setup_app()
log.info('Pecan app setup complete...')
host, port = cfg.CONF.gapi.host, cfg.CONF.gapi.port
log.info('Galaxia api server started in PID %s' % os.getpid())
log.info('Galaxia API is now serving on http://%(host)s:%(port)s' % dict(
host=host, port=port))
print ('Galaxia API is now serving on http://%(host)s:%(port)s' % dict(
host=host, port=port))
wsgi.server(eventlet.listen((host, port)), app, log=log)
示例9: __init__
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def __init__(self, url):
self.host, port_str = url.split(':')
self.port = int(port_str)
self.server = None
# create the thread object
self.thread = threading.Thread(target=self._start_listening_blocking)
# wrap Flask application with socketio's middleware
self.app = socketio.Middleware(sio, app)
示例10: _start_listening_blocking
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def _start_listening_blocking(self):
# deploy as an eventlet WSGI server
listener = eventlet.listen((self.host, self.port))
self.server = wsgi.server(listener, self.app, log_output=False, debug=False)
示例11: script_name
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def script_name(self):
''' The initial portion of the URL's `path` that was removed by a higher
level (server or routing middleware) before the application was
called. This script path is returned with leading and tailing
slashes. '''
script_name = self.environ.get('SCRIPT_NAME', '').strip('/')
return '/' + script_name + '/' if script_name else '/'
示例12: auth
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def auth(self):
""" HTTP authentication data as a (user, password) tuple. This
implementation currently supports basic (not digest) authentication
only. If the authentication happened at a higher level (e.g. in the
front web-server or a middleware), the password field is None, but
the user field is looked up from the ``REMOTE_USER`` environ
variable. On any errors, None is returned. """
basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION',''))
if basic: return basic
ruser = self.environ.get('REMOTE_USER')
if ruser: return (ruser, None)
return None
示例13: run
# 需要导入模块: from eventlet import wsgi [as 别名]
# 或者: from eventlet.wsgi import server [as 别名]
def run(self, handler): # pragma: no cover
import flup.server.fcgi
self.options.setdefault('bindAddress', (self.host, self.port))
flup.server.fcgi.WSGIServer(handler, **self.options).run()