Skip to main content

The library provides file sessions store for aiohttp.web.

Usage

A trivial usage example:

import asyncio
import shutil
import tempfile
import time

from aiohttp import web
from aiohttp_session import setup, get_session
from aiohttp_session_file import FileStorage


async def handler(request):
    session = await get_session(request)
    last_visit = session['last_visit'] if 'last_visit' in session else None
    session['last_visit'] = time.time()
    text = 'Last visited: {}'.format(last_visit)
    return web.Response(text=text)


async def setup_dir(app):
    dirpath = tempfile.mkdtemp(prefix='aiohttp-session-')

    async def remove_dir(app):
        shutil.rmtree(dirpath)

    app.on_cleanup.append(remove_dir)
    return dirpath


async def make_app():
    app = web.Application()

    dirpath = await setup_dir(app)

    max_age = 3600 * 24 * 365  # 1 year
    setup(app, FileStorage(dirpath, max_age=max_age))

    app.router.add_get('/', handler)
    return app


web.run_app(make_app())

Metadata

Release files for aiohttp-session-file 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-session-file 0.0.3
File Size Uploaded
aiohttp-session-file-0.0.3.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-session-file 0.0.3
File Interpreter ABI Platform
aiohttp_session_file-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / aiohttp-session-file-0.0.3.tar.gz

Download URL aiohttp-session-file-0.0.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
594704748db93786de0b9c2355c03e6eb151f2f9c97352d89f3bb3e85c23dc13
BLAKE2b-256 checksum
How to use checksums
c8bf44fcf7bf62cefae3fb14c31ec22ea008f1ad6c8afab6b6bb830923d3f43e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.1

Release files / aiohttp_session_file-0.0.3-py3-none-any.whl

Download URL aiohttp_session_file-0.0.3-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eb7fe106d52413483bf39c4807a73b7f8b8f7644e9b623254ea7220b0ccefc5
BLAKE2b-256 checksum
How to use checksums
8002e307c81219ded1fd818eeded62c7d9db8957e1883c2aed4b47f35e946a90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page