當前位置: 首頁>>代碼示例>>Python>>正文


Python pywsgi.WSGIServer方法代碼示例

本文整理匯總了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() 
開發者ID:openprocurement,項目名稱:openprocurement.auction,代碼行數:22,代碼來源:chronograph.py

示例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 
開發者ID:opteroncx,項目名稱:MoePhoto,代碼行數:24,代碼來源:server.py

示例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() 
開發者ID:plasticityai,項目名稱:magnitude,代碼行數:21,代碼來源:config_explorer.py

示例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 
開發者ID:dagster-io,項目名稱:dagster,代碼行數:22,代碼來源:test_cli.py

示例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,
            ) 
開發者ID:raiden-network,項目名稱:raiden-services,代碼行數:27,代碼來源:api.py

示例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() 
開發者ID:artisan-roaster-scope,項目名稱:artisan,代碼行數:18,代碼來源:weblcds.py

示例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() 
開發者ID:Jahaja,項目名稱:psdash,代碼行數:24,代碼來源:run.py

示例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() 
開發者ID:pebble,項目名稱:pypkjs,代碼行數:24,代碼來源:websocket.py

示例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() 
開發者ID:DuckBoss,項目名稱:JJMumbleBot,代碼行數:6,代碼來源:web_helper.py

示例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() 
開發者ID:jtyoui,項目名稱:Jtyoui,代碼行數:6,代碼來源:keras_web.py

示例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]) 
開發者ID:soundcloud,項目名稱:project-dev-kpis,代碼行數:8,代碼來源:api_server.py

示例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) 
開發者ID:linkedin,項目名稱:iris-relay,代碼行數:9,代碼來源:app.py

示例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() 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:28,代碼來源:server.py

示例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() 
開發者ID:liwanlei,項目名稱:FXTest,代碼行數:6,代碼來源:manage.py

示例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) 
開發者ID:OpenMTC,項目名稱:OpenMTC,代碼行數:4,代碼來源:__init__.py


注:本文中的gevent.pywsgi.WSGIServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。