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


Python wsgi.PathInfoDispatcher方法代碼示例

本文整理匯總了Python中cheroot.wsgi.PathInfoDispatcher方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgi.PathInfoDispatcher方法的具體用法?Python wsgi.PathInfoDispatcher怎麽用?Python wsgi.PathInfoDispatcher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cheroot.wsgi的用法示例。


在下文中一共展示了wsgi.PathInfoDispatcher方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: start

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def start(self):
        d = PathInfoDispatcher({"/": self.app})
        self.server = Server(("0.0.0.0", self.proxyport), d)
        self.proxy_thread = threading.Thread(target=self.server.start)
        self.proxy_thread.daemon = True
        self.proxy_thread.start()
        BitcoinD.start(self)

        # Now that bitcoind is running on the real rpcport, let's tell all
        # future callers to talk to the proxyport. We use the bind_addr as a
        # signal that the port is bound and accepting connections.
        while self.server.bind_addr[1] == 0:
            pass
        self.proxiedport = self.rpcport
        self.rpcport = self.server.bind_addr[1]
        logging.debug(
            "bitcoind reverse proxy listening on {}, forwarding to {}".format(
                self.rpcport, self.proxiedport
            )
        ) 
開發者ID:willcl-ark,項目名稱:lnd_grpc,代碼行數:22,代碼來源:btcproxy.py

示例2: _start_monitoring_api_thread

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def _start_monitoring_api_thread(self, host, port, warn_on_update):
        """
        Threaded method that servces the monitoring api

        :param host: IP or hostname to use
        :type host: str
        :param port: Port to use
        :type port: int
        :param warn_on_update: Should the monitoring system report available updates?
        :type warn_on_update: bool
        """
        logging.info("Starting monitoring API service ...")
        app = Flask(__name__)
        @app.route('/')
        @app.route('/status/')
        def redirect_to_wiki():
            logging.debug("Visit https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/UNICORN-"
                          "Monitoring-API-Service for further information!")
            return redirect("https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/"
                            "UNICORN-Monitoring-API-Service", code=302)

        api = Api(app)
        api.add_resource(BinanceWebSocketApiRestServer,
                         "/status/<string:statusformat>/",
                         "/status/<string:statusformat>/<string:checkcommandversion>",
                         resource_class_kwargs={'handler_binance_websocket_api_manager': self,
                                                'warn_on_update': warn_on_update})
        try:
            dispatcher = wsgi.PathInfoDispatcher({'/': app})
            self.monitoring_api_server = wsgi.WSGIServer((host, port), dispatcher)
            self.monitoring_api_server.start()
        except RuntimeError as error_msg:
            logging.critical("Monitoring API service is going down! - Info: " + str(error_msg))
        except OSError as error_msg:
            logging.critical("Monitoring API service is going down! - Info: " + str(error_msg)) 
開發者ID:oliver-zehentleitner,項目名稱:unicorn-binance-websocket-api,代碼行數:37,代碼來源:unicorn_binance_websocket_api_manager.py

示例3: run

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def run(self):
        self._configure_flask_app()
        dispatcher = PathInfoDispatcher({"/": app})
        self.server = WSGIServer((self.host, self.port), dispatcher)
        self.server.start() 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:7,代碼來源:web_app.py

示例4: start_web_rest_server

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def start_web_rest_server(models, rest_port, num_threads):
    d = PathInfoDispatcher({'/': create_rest_api(models)})
    server = WSGIServer(('0.0.0.0', rest_port), d,
                        numthreads=num_threads,
                        request_queue_size=GLOBAL_CONFIG[
                            'rest_requests_queue_size'])
    logger.info("REST server listens on port {port} and will be "
                "serving models: {models}".format(port=rest_port,
                                                  models=list(models.keys())))
    try:
        server.start()
    except KeyboardInterrupt:
        server.stop() 
開發者ID:openvinotoolkit,項目名稱:model_server,代碼行數:15,代碼來源:start.py

示例5: test_dispatch_no_script_name

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def test_dispatch_no_script_name():
    """Dispatch despite lack of ``SCRIPT_NAME`` in environ."""
    # Bare bones WSGI hello world app (from PEP 333).
    def app(environ, start_response):
        start_response(
            '200 OK', [
                ('Content-Type', 'text/plain; charset=utf-8'),
            ],
        )
        return [u'Hello, world!'.encode('utf-8')]

    # Build a dispatch table.
    d = PathInfoDispatcher([
        ('/', app),
    ])

    # Dispatch a request without `SCRIPT_NAME`.
    response = wsgi_invoke(
        d, {
            'PATH_INFO': '/foo',
        },
    )
    assert response == {
        'status': '200 OK',
        'headers': [
            ('Content-Type', 'text/plain; charset=utf-8'),
        ],
        'body': b'Hello, world!',
    } 
開發者ID:cherrypy,項目名稱:cheroot,代碼行數:31,代碼來源:test_dispatch.py

示例6: test_dispatch_no_script_name

# 需要導入模塊: from cheroot import wsgi [as 別名]
# 或者: from cheroot.wsgi import PathInfoDispatcher [as 別名]
def test_dispatch_no_script_name():
    """Despatch despite lack of SCRIPT_NAME in environ."""
    # Bare bones WSGI hello world app (from PEP 333).
    def app(environ, start_response):
        start_response(
            '200 OK', [
                ('Content-Type', 'text/plain; charset=utf-8'),
            ],
        )
        return [u'Hello, world!'.encode('utf-8')]

    # Build a dispatch table.
    d = PathInfoDispatcher([
        ('/', app),
    ])

    # Dispatch a request without `SCRIPT_NAME`.
    response = wsgi_invoke(
        d, {
            'PATH_INFO': '/foo',
        },
    )
    assert response == {
        'status': '200 OK',
        'headers': [
            ('Content-Type', 'text/plain; charset=utf-8'),
        ],
        'body': b'Hello, world!',
    } 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:31,代碼來源:test_dispatch.py


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