当前位置: 首页>>代码示例>>Python>>正文


Python Application.get方法代码示例

本文整理汇总了Python中aiohttp.web.Application.get方法的典型用法代码示例。如果您正苦于以下问题:Python Application.get方法的具体用法?Python Application.get怎么用?Python Application.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.web.Application的用法示例。


在下文中一共展示了Application.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup

# 需要导入模块: from aiohttp.web import Application [as 别名]
# 或者: from aiohttp.web.Application import get [as 别名]
def setup(
    app: web.Application, *,
    append_slash: bool=DEFAULTS['APPEND_SLASH'],
    merge_slashes: bool=DEFAULTS['MERGE_SLASHES']
):
    """Set up the path normalization middleware. Reads configuration from
    ``app['AIOHTTP_UTILS']``.

    :param app: Application to set up.
    :param append_slash: Whether to append trailing slashes to URLs.
    :param merge_slashes: Whether to merge multiple slashes in URLs to a single
        slash
    """
    config = app.get(CONFIG_KEY, {})
    middleware = normalize_path_middleware(
        append_slash=config.get('APPEND_SLASH', append_slash),
        merge_slashes=config.get('MERGE_SLASHES', merge_slashes),
    )
    app.middlewares.append(middleware)
    return app
开发者ID:ox-it,项目名称:aiohttp_utils,代码行数:22,代码来源:path_norm.py

示例2: setup

# 需要导入模块: from aiohttp.web import Application [as 别名]
# 或者: from aiohttp.web.Application import get [as 别名]
def setup(
    app: web.Application, *, negotiator: callable=DEFAULTS['NEGOTIATOR'],
    renderers: OrderedDict=DEFAULTS['RENDERERS'],
    force_negotiation: bool=DEFAULTS['FORCE_NEGOTIATION']
):
    """Set up the negotiation middleware. Reads configuration from
    ``app['AIOHTTP_UTILS']``.

    :param app: Application to set up.
    :param negotiator: Function that selects a renderer given a
        request, a dict of renderers, and a ``force`` parameter (whether to return
        a renderer even if the client passes an unsupported media type).
    :param renderers: Mapping of mediatypes to callable renderers.
    :param force_negotiation: Whether to return a rennderer even if the
        client passes an unsupported media type).
    """
    config = app.get(CONFIG_KEY, {})
    middleware = negotiation_middleware(
        renderers=config.get('RENDERERS', renderers),
        negotiator=config.get('NEGOTIATOR', negotiator),
        force_negotiation=config.get('FORCE_NEGOTIATION', force_negotiation)
    )
    app.middlewares.append(middleware)
    return app
开发者ID:adamchainz,项目名称:aiohttp_utils,代码行数:26,代码来源:negotiation.py


注:本文中的aiohttp.web.Application.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。