当前位置: 首页>>代码示例>>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;未经允许,请勿转载。