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())

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp-session-file-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiohttp_session_file-0.0.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp-session-file-0.0.3.tar.gz.

File metadata

  • Download URL: aiohttp-session-file-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for aiohttp-session-file-0.0.3.tar.gz
Algorithm Hash digest
SHA256 594704748db93786de0b9c2355c03e6eb151f2f9c97352d89f3bb3e85c23dc13
MD5 62a7100fedf79d5e3260bc57a63094fd
BLAKE2b-256 c8bf44fcf7bf62cefae3fb14c31ec22ea008f1ad6c8afab6b6bb830923d3f43e

See more details on using hashes here.

File details

Details for the file aiohttp_session_file-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_session_file-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for aiohttp_session_file-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb7fe106d52413483bf39c4807a73b7f8b8f7644e9b623254ea7220b0ccefc5
MD5 cbb0a2914b6b7831b3ff8774e112a8c5
BLAKE2b-256 8002e307c81219ded1fd818eeded62c7d9db8957e1883c2aed4b47f35e946a90

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page