本文整理汇总了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
示例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
)