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