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


Python aiohttp_session.session_middleware方法代码示例

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


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

示例1: init

# 需要导入模块: import aiohttp_session [as 别名]
# 或者: from aiohttp_session import session_middleware [as 别名]
def init(loop):
    conf = load_config(str(PROJ_ROOT / 'config' / 'config.yml'))

    app = web.Application(loop=loop)
    cookie_storage = SimpleCookieStorage()
    app = web.Application(middlewares=[session_middleware(cookie_storage)])
    mongo = await setup_mongo(app, conf, loop)

    setup_jinja(app)

    admin = setup_admin(app, mongo)
    app.add_subapp('/admin', admin)

    app.router.add_static('/static', path=str(PROJ_ROOT / 'static'))

    # setup views and routes
    handler = SiteHandler(mongo)
    setup_routes(app, handler, PROJ_ROOT)

    host, port = conf['host'], conf['port']
    return app, host, port 
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:23,代码来源:main.py

示例2: make_app

# 需要导入模块: import aiohttp_session [as 别名]
# 或者: from aiohttp_session import session_middleware [as 别名]
def make_app():
    #
    # WARNING!!!
    # Never use SimpleCookieStorage on production!!!
    # It’s highly insecure!!!
    #

    # make app
    middleware = session_middleware(SimpleCookieStorage())
    app = web.Application(middlewares=[middleware])

    # add the routes
    app.router.add_route('GET', '/', handler_root)
    app.router.add_route('GET', '/login', handler_login_jack)
    app.router.add_route('GET', '/logout', handler_logout)
    app.router.add_route('GET', '/listen', handler_listen)
    app.router.add_route('GET', '/speak', handler_speak)

    # set up policies
    policy = SessionIdentityPolicy()
    setup_security(app, policy, SimpleJack_AuthorizationPolicy())

    return app 
开发者ID:aio-libs,项目名称:aiohttp-security,代码行数:25,代码来源:simple_example_auth.py

示例3: create_app

# 需要导入模块: import aiohttp_session [as 别名]
# 或者: from aiohttp_session import session_middleware [as 别名]
def create_app(handler, memcached, max_age=None,
               key_factory=lambda: uuid.uuid4().hex):
    middleware = session_middleware(
        MemcachedStorage(memcached, max_age=max_age, key_factory=key_factory))
    app = web.Application(middlewares=[middleware])
    app.router.add_route('GET', '/', handler)
    return app 
开发者ID:aio-libs,项目名称:aiohttp-session,代码行数:9,代码来源:test_memcached_storage.py

示例4: create_app

# 需要导入模块: import aiohttp_session [as 别名]
# 或者: from aiohttp_session import session_middleware [as 别名]
def create_app(handler, redis, max_age=None,
               key_factory=lambda: uuid.uuid4().hex):
    middleware = session_middleware(
        RedisStorage(redis, max_age=max_age, key_factory=key_factory))
    app = web.Application(middlewares=[middleware])
    app.router.add_route('GET', '/', handler)
    return app 
开发者ID:aio-libs,项目名称:aiohttp-session,代码行数:9,代码来源:test_redis_storage.py

示例5: session_middleware

# 需要导入模块: import aiohttp_session [as 别名]
# 或者: from aiohttp_session import session_middleware [as 别名]
def session_middleware(request, handler):
    """Wrapper to Session Middleware factory.
    """
    # Do the trick, by passing app & handler back to original session
    # middleware factory. Do not forget to await on results here as original
    # session middleware factory is also awaitable.
    app = request.app
    storage = RedisStorage(app['redis'], httponly=False)
    middleware = session_middleware_(storage)
    return await middleware(request, handler) 
开发者ID:anxolerd,项目名称:dvpwa,代码行数:12,代码来源:middlewares.py


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