Skip to main content

A simple, file-based session middleware for Tremolo.

Project description

tremolo-session

A simple, file-based session middleware for Tremolo.

See also: tremolo-login.

Usage

#!/usr/bin/env python3

from tremolo import Tremolo
from tremolo_session import Session

app = Tremolo()

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


@app.route('/')
async def index(request=None, **server):
    session = request.context.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 alltests.py.

Or if you also want measurements with coverage:

coverage run alltests.py
coverage combine
coverage report
coverage html # to generate html reports

License

MIT

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.4.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file tremolo-session-1.0.4.tar.gz.

File metadata

  • Download URL: tremolo-session-1.0.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for tremolo-session-1.0.4.tar.gz
Algorithm Hash digest
SHA256 65c72645e1a46609655727ffcbcc46e4d16861b1ba4505d365621d410fe7cf8c
MD5 1593dace099f80f7222dd9ac3ef92a8a
BLAKE2b-256 9c5633025bdef72155ca21950720058e08c8cb1fe5a379be35f792b93e8dc1e7

See more details on using hashes here.

Supported by

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