Skip to main content

tremolo-session

Coverage Quality Gate Status

A simple, file-based session middleware for Tremolo.

See also: tremolo-login.

Usage

#!/usr/bin/env python3

from tremolo import Application
from tremolo_session import Session

app = Application()

# this is a session middleware
# that enables you to use request.ctx.session
Session(app, expires=86400)


@app.route('/')
async def index(request, **server):
    session = request.ctx.session

    if session is None:
        return b'The session will be created after you reload this page.'

    if 'visits' in session:
        session['visits'] += 1
    else:
        session['visits'] = 0

    return b'You have visited this page %d times today.' % session['visits']


if __name__ == '__main__':
    app.run('0.0.0.0', 8000, debug=True, reload=True)

Installing

python3 -m pip install --upgrade tremolo_session

Testing

Just run python3 -m tests.

Or if you also want measurements with coverage:

coverage run -m tests
coverage combine
coverage report
coverage html # to generate html reports

License

MIT License

Release files for tremolo-session 1.0.13

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

Source distribution (sdist)

Source distribution for tremolo-session 1.0.13
File Size Uploaded
tremolo_session-1.0.13.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tremolo-session 1.0.13
File Interpreter ABI Platform
tremolo_session-1.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / tremolo_session-1.0.13.tar.gz

Download URL tremolo_session-1.0.13.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3e06482c1e29e29120025f46b2526f3f403eb7edd35535d484d4971109cb887a
BLAKE2b-256 checksum
How to use checksums
43ff388571536bd3346621d2d5f6e1fe68f5690b94ca4ad35967f0eb58fb2dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.11

Release files / tremolo_session-1.0.13-py3-none-any.whl

Download URL tremolo_session-1.0.13-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8458ee762a008219afd39feb0c68fca0489f4cfecdf6c2ab93be8d37099c502
BLAKE2b-256 checksum
How to use checksums
3bdfafd7fec3879b854bfcb40096f057f310175ebe56f25e8366d676334d5ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.11

Release history Release notifications | RSS feed

This release

1.0.13 This release

2 release files

1.0.11

2 release files

1.0.8

2 release files

1.0.6

2 release files

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

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