本文整理汇总了Python中gevent.wsgi.WSGIServer方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.WSGIServer方法的具体用法?Python wsgi.WSGIServer怎么用?Python wsgi.WSGIServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gevent.wsgi
的用法示例。
在下文中一共展示了wsgi.WSGIServer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _start_web
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def _start_web(port, sentry_dsn=None, blueprints=None):
"""
Starts a Flask app with optional error logging and blueprint registration.
Args:
port - str/int - port on which management application should listen for
HTTP traffic.
sentry_dsn - str - Sentry DSN for error logging.
blueprints - list(flask.Blueprint)- blueprints to register.
"""
# Set up management application
app = Flask(__name__)
app.register_blueprint(lifecycle_blueprint)
if blueprints:
for blueprint in blueprints:
app.register_blueprint(blueprint)
if sentry_dsn:
app = setup_sentry_wsgi(app, sentry_dsn)
http_server = WSGIServer(('0.0.0.0', int(port)), app)
http_server.serve_forever()
示例2: run
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def run(self, app): # pragma: no cover
from wsgiref.simple_server import WSGIRequestHandler, WSGIServer
from wsgiref.simple_server import make_server
import socket
class FixedHandler(WSGIRequestHandler):
def address_string(self): # Prevent reverse DNS lookups please.
return self.client_address[0]
def log_request(*args, **kw):
if not self.quiet:
return WSGIRequestHandler.log_request(*args, **kw)
handler_cls = self.options.get('handler_class', FixedHandler)
server_cls = self.options.get('server_class', WSGIServer)
if ':' in self.host: # Fix wsgiref for IPv6 addresses.
if getattr(server_cls, 'address_family') == socket.AF_INET:
class server_cls(server_cls):
address_family = socket.AF_INET6
srv = make_server(self.host, self.port, app, server_cls, handler_cls)
srv.serve_forever()
示例3: launch
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def launch(app):
http_server = WSGIServer(('', app.config['XCESSIV_PORT']), app)
webbrowser.open_new('http://localhost:' + str(app.config['XCESSIV_PORT']))
http_server.serve_forever()
示例4: run
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [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()
示例5: __init__
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def __init__(self, options=None):
self.args_options = options or {}
os.environ['APPR_DB_CLASS'] = self.args_options.db_class
print("Listening %s:%s" % (self.args_options.bind, self.args_options.port))
self.http_server = WSGIServer((self.args_options.bind, self.args_options.port),
create_app())
示例6: _record_messages
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def _record_messages(self, on_message):
from flask import Flask
app = Flask(__name__)
for component in self.listener_components:
if self._has_root_prefix():
app.register_blueprint(component.blueprint(on_message))
else:
app.register_blueprint(component.blueprint(on_message),
url_prefix=self.url_prefix)
from gevent.wsgi import WSGIServer
http_server = WSGIServer(('0.0.0.0', self.http_port), app)
http_server.serve_forever()
示例7: serve_forever
# 需要导入模块: from gevent import wsgi [as 别名]
# 或者: from gevent.wsgi import WSGIServer [as 别名]
def serve_forever(self):
debug = self.app.config.get('DEBUG', True)
host = self.app.config.get('HOST', 'localhost')
port = self.app.config.get('PORT', 5000)
if not debug:
from gevent.wsgi import WSGIServer
http_server = WSGIServer((host, port), self.app, log=debug)
http_server.serve_forever()
else:
self.app.run(host, port)