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


Python routing.URLRouter方法代碼示例

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


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

示例1: _prepare_ws_urlpatterns

# 需要導入模塊: from channels import routing [as 別名]
# 或者: from channels.routing import URLRouter [as 別名]
def _prepare_ws_urlpatterns(app_set):
        """
        Generate WS URL patterns for the given list of tuples of apps and
        configuration objects
        :param app_set: the given list of tuples of apps and their configuration
        objects
        :return: the WS URL patterns
        """

        ws_urlpatterns = list()
        for (app, app_configuration) in app_set:
            if app_configuration.is_allowed:
                url = app_configuration.base_urls.ws
                if url is not None:
                    module = importlib.import_module(f'{app}.ws_urls')
                    dictionary = module.__dict__
                    app_urlpatterns = dictionary['urlpatterns']
                    url_router = URLRouter(app_urlpatterns)
                    ws_urlpatterns.append(
                        path(url, url_router)
                    )
        return ws_urlpatterns 
開發者ID:IMGIITRoorkee,項目名稱:omniport-backend,代碼行數:24,代碼來源:discovery.py

示例2: get_protocol_type_router

# 需要導入模塊: from channels import routing [as 別名]
# 或者: from channels.routing import URLRouter [as 別名]
def get_protocol_type_router(self, tenant_prefix, ws_urlconf):
        """
        Subclasses can override this to include more protocols.
        """
        return TenantAwareProtocolTypeRouter(
            {"websocket": TenantAuthMiddlewareStack(URLRouter(ws_urlconf))}, tenant_prefix
        ) 
開發者ID:lorinkoz,項目名稱:django-pgschemas,代碼行數:9,代碼來源:router.py


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