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


Python aiohttp_session.SimpleCookieStorage方法代碼示例

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


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

示例1: init

# 需要導入模塊: import aiohttp_session [as 別名]
# 或者: from aiohttp_session import SimpleCookieStorage [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 SimpleCookieStorage [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 SimpleCookieStorage [as 別名]
def create_app(handler):
    app = web.Application()
    setup_middleware(app, SimpleCookieStorage(max_age=10))
    app.router.add_route('GET', '/', handler)
    return app 
開發者ID:aio-libs,項目名稱:aiohttp-session,代碼行數:7,代碼來源:test_abstract_storage.py

示例4: make_app

# 需要導入模塊: import aiohttp_session [as 別名]
# 或者: from aiohttp_session import SimpleCookieStorage [as 別名]
def make_app():
    app = web.Application()
    setup_session(app, SimpleCookieStorage())
    setup_security(app, SessionIdentityPolicy(), Autz())
    return app 
開發者ID:aio-libs,項目名稱:aiohttp-security,代碼行數:7,代碼來源:test_session_identity.py

示例5: create_app

# 需要導入模塊: import aiohttp_session [as 別名]
# 或者: from aiohttp_session import SimpleCookieStorage [as 別名]
def create_app(loop, db):
    app = web.Application(loop=loop, middlewares=[
        session_middleware(SimpleCookieStorage()),
    ])
    app.middlewares.append(aiohttp_login.flash.middleware)
    aiohttp_jinja2.setup(
        app,
        loader=jinja_app_loader.Loader(),
        context_processors=[aiohttp_login.flash.context_processor],
    )

    if db == 'asyncpg':
        pool = await asyncpg.create_pool(
            dsn='postgres:///' + DATABASE, loop=loop)
        storage = AsyncpgStorage(pool)
    elif db == 'motor':
        app['db'] = AsyncIOMotorClient(io_loop=loop)[DATABASE]
        storage = MotorStorage(app['db'])
    else:
        assert 0, 'unknown storage'

    aiohttp_login.setup(app, storage, {
        'CSRF_SECRET': 'secret',
        'LOGIN_REDIRECT': 'auth_change_email',
        'SMTP_SENDER': 'Your Name <your@gmail.com>',
        'SMTP_HOST': 'smtp.gmail.com',
        'SMTP_PORT': 465,
        'SMTP_USERNAME': 'your@gmail.com',
        'SMTP_PASSWORD': 'password'
    })

    @restricted_api
    async def api_hello_handler(request):
        return {'hello': 'world'}

    app.router.add_get('/api/hello', api_hello_handler, name='api_hello')

    return app 
開發者ID:imbolc,項目名稱:aiohttp-login,代碼行數:40,代碼來源:utils.py

示例6: init_app

# 需要導入模塊: import aiohttp_session [as 別名]
# 或者: from aiohttp_session import SimpleCookieStorage [as 別名]
def init_app() -> web.Application:
    app = web.Application(client_max_size=64 * 1024 ** 2)
    app.add_routes(router)
    app.cleanup_ctx.append(init_db)
    aiohttp_session.setup(app, aiohttp_session.SimpleCookieStorage())
    aiohttp_jinja2.setup(
        app,
        loader=jinja2.FileSystemLoader(str(Path(__file__).parent / "templates")),
        context_processors=[username_ctx_processor],
    )
    app.middlewares.append(error_middleware)
    app.middlewares.append(check_login)

    return app 
開發者ID:asvetlov,項目名稱:us-pycon-2019-tutorial,代碼行數:16,代碼來源:01-login-session.py

示例7: init_app

# 需要導入模塊: import aiohttp_session [as 別名]
# 或者: from aiohttp_session import SimpleCookieStorage [as 別名]
def init_app(db_path: Path) -> web.Application:
    app = web.Application(client_max_size=64 * 1024 ** 2)
    app["DB_PATH"] = db_path
    app.add_routes(router)
    app.cleanup_ctx.append(init_db)
    aiohttp_session.setup(app, aiohttp_session.SimpleCookieStorage())
    aiohttp_jinja2.setup(
        app,
        loader=jinja2.FileSystemLoader(str(Path(__file__).parent / "templates")),
        context_processors=[username_ctx_processor],
    )
    app.middlewares.append(error_middleware)
    app.middlewares.append(check_login)

    return app 
開發者ID:asvetlov,項目名稱:us-pycon-2019-tutorial,代碼行數:17,代碼來源:server.py


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