Skip to main content

A simple, file-based session middleware for Tremolo.

Project description

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

Project details


Download files

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

Source Distribution

tremolo_session-1.0.13.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

tremolo_session-1.0.13-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file tremolo_session-1.0.13.tar.gz.

File metadata

  • Download URL: tremolo_session-1.0.13.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.11

File hashes

Hashes for tremolo_session-1.0.13.tar.gz
Algorithm Hash digest
SHA256 3e06482c1e29e29120025f46b2526f3f403eb7edd35535d484d4971109cb887a
MD5 8e4a7b228fdc50cad57a882fc42debf9
BLAKE2b-256 43ff388571536bd3346621d2d5f6e1fe68f5690b94ca4ad35967f0eb58fb2dac

See more details on using hashes here.

File details

Details for the file tremolo_session-1.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for tremolo_session-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 e8458ee762a008219afd39feb0c68fca0489f4cfecdf6c2ab93be8d37099c502
MD5 e68b2ba9a1f23e7fc25d61fa916ed46e
BLAKE2b-256 3bdfafd7fec3879b854bfcb40096f057f310175ebe56f25e8366d676334d5ba1

See more details on using hashes here.

Supported by

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