本文整理汇总了Python中gevent.pywsgi.WSGIServer方法的典型用法代码示例。如果您正苦于以下问题:Python pywsgi.WSGIServer方法的具体用法?Python pywsgi.WSGIServer怎么用?Python pywsgi.WSGIServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gevent.pywsgi
的用法示例。
在下文中一共展示了pywsgi.WSGIServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_web_app
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def init_web_app(self):
self.web_application = chronograph_webapp
self.web_application.chronograph = self
location = self.config['main'].get('web_app')
if ':' in str(location):
if not location.startswith('//'):
location = "//{}".format(location)
o = urlparse(location)
self.server = WSGIServer(
get_lisener(o.port, o.hostname),
self.web_application,
spawn=100
)
else:
self.server = WSGIServer(
get_lisener(location),
self.web_application,
spawn=100
)
self.server.start()
示例2: runserver
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def runserver(taskInSender, taskOutReceiver, noteReceiver, stopEvent, mm, isWindows):
global sender, receiver, noter
sender = taskInSender
receiver = taskOutReceiver
noter = noteReceiver
current.stopFlag = stopEvent
mmView = memoryview(mm) if isWindows else mm.buf
current.getPreview = lambda: BytesIO(mmView[:current.fileSize])
if not isWindows:
mm = mm.buf.obj
def writeFile(file):
mm.seek(0)
return file._file.readinto(mm)
current.writeFile = writeFile
def f(host, port):
app.debug = False
app.config['SERVER_NAME'] = None
server = pywsgi.WSGIServer((host, port), app, environ={'SERVER_NAME': ''})
print('Current working directory: {}'.format(cwd))
print('Server starts to listen on http://{}:{}/, press Ctrl+C to exit.'.format(host, port))
server.serve_forever()
return f
示例3: main
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def main(args):
parser = argparse.ArgumentParser(description=u'Serve up a simple configuration wizard')
parser.add_argument(u'--port', type=int, default=8123, help=u'port to serve the wizard on')
parser.add_argument(u'--include-package',
type=unicode,
action=u'append',
default=[],
help=u'additional packages to include')
args = parser.parse_args(args)
app = make_app(args.include_package)
CORS(app)
http_server = WSGIServer((u'0.0.0.0', args.port), app)
print("serving Config Explorer on port {args.port}")
http_server.serve_forever()
示例4: test_invoke_ui_with_port_taken
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def test_invoke_ui_with_port_taken(monkeypatch):
def serve_forever(self):
if self.server_port == 3000:
raise OSError('Address already in use')
monkeypatch.setattr(pywsgi.WSGIServer, 'serve_forever', serve_forever)
runner = CliRunner()
result = runner.invoke(
ui,
['-f', file_relative_path(__file__, './pipeline.py'), '-a', 'test_repository'],
input="n\n",
)
assert result.exception
result = runner.invoke(
ui,
['-f', file_relative_path(__file__, './pipeline.py'), '-a', 'test_repository'],
input="y\n",
)
assert ':3001' in result.output
示例5: __init__
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def __init__(
self,
monitoring_service: MonitoringService,
operator: str,
info_message: str = DEFAULT_INFO_MESSAGE,
) -> None:
self.flask_app = Flask(__name__)
self.api = ApiWithErrorHandler(self.flask_app)
self.rest_server: Optional[WSGIServer] = None
self.monitoring_service = monitoring_service
self.operator = operator
self.info_message = info_message
resources: List[Tuple[str, Resource, str]] = [
("/info", cast(Resource, InfoResource), "info"),
]
for endpoint_url, resource, endpoint in resources:
self.api.add_resource(
resource,
API_PATH + endpoint_url,
resource_class_kwargs={"monitoring_service": monitoring_service, "api": self},
endpoint=endpoint,
)
示例6: work
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def work(p,rp,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,showbtflag):
global port, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showbt, showet
port = p
static_path = rp
nonesymbol = nonesym
timecolor = timec
timebackground = timebg
btcolor = btc
btbackground = btbg
etcolor = etc
etbackground = etbg
showet = showetflag
showbt = showbtflag
TEMPLATE_PATH.insert(0,rp)
s = WSGIServer(("0.0.0.0", p), default_app(), handler_class=WebSocketHandler)
s.serve_forever()
示例7: _run_web
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def _run_web(self):
logger.info("Starting web server")
log = 'default' if self.app.debug else None
ssl_args = {}
if self.app.config.get('PSDASH_HTTPS_KEYFILE') and self.app.config.get('PSDASH_HTTPS_CERTFILE'):
ssl_args = {
'keyfile': self.app.config.get('PSDASH_HTTPS_KEYFILE'),
'certfile': self.app.config.get('PSDASH_HTTPS_CERTFILE')
}
listen_to = (
self.app.config.get('PSDASH_BIND_HOST', self.DEFAULT_BIND_HOST),
self.app.config.get('PSDASH_PORT', self.DEFAULT_PORT)
)
self.server = WSGIServer(
listen_to,
application=self.app,
log=log,
**ssl_args
)
self.server.serve_forever()
示例8: run
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def run(self):
pebble_greenlet = self.pebble.connect()
self.pebble.pebble.register_raw_inbound_handler(self._handle_inbound)
self.pebble.pebble.register_raw_outbound_handler(self._handle_outbound)
if self.pebble.timeline_is_supported:
self.timeline.continuous_sync()
self.timeline.do_maintenance()
logging.getLogger().addHandler(WebsocketLogHandler(self, level=logging.WARNING))
if self.ssl_root is not None:
ssl_args = {
'keyfile': '%s/server-key.pem' % self.ssl_root,
'certfile': '%s/server-cert.pem' % self.ssl_root,
'ca_certs': '%s/ca-cert.pem' % self.ssl_root,
'ssl_version': ssl.PROTOCOL_TLSv1,
}
else:
ssl_args = {}
self.server = pywsgi.WSGIServer(("", self.port), self.handle_ws, handler_class=WebSocketHandler, **ssl_args)
gevent.spawn(self.server.serve_forever)
pebble_greenlet.join()
self.server.close()
self.pebble.disconnect()
示例9: start_flask_server
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def start_flask_server():
global_settings.flask_server = WSGIServer((global_settings.cfg[C_WEB_SETTINGS][P_WEB_IP], int(global_settings.cfg[C_WEB_SETTINGS][P_WEB_PAGE_PORT])),
web_app, log=None)
global_settings.flask_server.serve_forever()
示例10: remote_monitor
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def remote_monitor(listener='localhost', port=9000):
print(f'点击链接:http://{listener}:{port}\t')
server = WSGIServer((listener, port), app)
server.serve_forever()
示例11: __init__
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def __init__(self, confs, max_sequential_errors, port):
self.max_sequential_errors = max_sequential_errors
self.sequential_errors = 0
self.server = WSGIServer(('0.0.0.0', port), flask_app)
self.server_proc = Process(target=lambda: self._serve())
ApiServer.conf_map = dict([(c['project_id'], c) for c in confs])
示例12: get_relay_server
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def get_relay_server():
from gevent.pywsgi import WSGIServer
config = read_config_from_argv()
app = get_relay_app(config)
server = config['server']
print(('LISTENING: %(host)s:%(port)d' % server))
return WSGIServer((server['host'], server['port']), app)
示例13: run_server
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def run_server(debug=False):
global app
config = settings.load()
attack.attack_url = config['links']['attack']
attack.proxies = config['links']['proxies']
interface = config['server']['interface']
port = config['server']['port']
threaded = True if debug else not async.enable_async()
flask_logger = configure_flask_logger()
connect_to_database()
# if not threaded and not debug:
ssl_context = {}
https = config['server']['https']
if https['enabled']:
ssl_context['certfile'] = https['certfile']
ssl_context['keyfile'] = https['keyfile']
app.debug = debug
print('Running CASCADE via WSGIServer on {url}'.format(url=config['server']['url']))
wsgi = WSGIServer((interface, port), app, log=flask_logger, handler_class=WebSocketHandler, **ssl_context)
wsgi.serve_forever()
示例14: app_start
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def app_start():
sched.start()
http_server = WSGIServer(('127.0.0.1', 5000), app)
http_server.serve_forever()
示例15: _get_server
# 需要导入模块: from gevent import pywsgi [as 别名]
# 或者: from gevent.pywsgi import WSGIServer [as 别名]
def _get_server(self):
return WSGIServer((self.listen_on, self.port), self.flask_app)