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 Tremolo
from tremolo_session import Session

app = Tremolo()

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


@app.route('/')
async def index(request=None, **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.8.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tremolo-session-1.0.8.tar.gz
  • Upload date:
  • Size: 4.3 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.8.tar.gz
Algorithm Hash digest
SHA256 1638333aa46b72092ea3214683b5ce652c2e2f75137eff12c7c4b1b205612ea9
MD5 5b2a2c5cce891e7732bd18a3081807bd
BLAKE2b-256 62a28294d4857f85ac56b9880b9d6cf69be4217247af93053ae6e53d39c5a24e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tremolo_session-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f553b4ea1630353b5a5521d74c389fda8715292bb9f7d6cc3eccd1a845d187d4
MD5 0c7fbc50fda9d23597d63adc785d6c7c
BLAKE2b-256 efededbc87ff085889757d98f7a7830bcb389aaae8707b2a05760a07db6d0a47

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