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

Uploaded Source

Built Distribution

tremolo_session-1.0.6-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tremolo-session-1.0.6.tar.gz
  • Upload date:
  • Size: 4.4 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.6.tar.gz
Algorithm Hash digest
SHA256 01581ee3545b7cefc1ad4d60d06fe325776a5e222918b6ee7cb8cc7161aaf6f6
MD5 67ab1c6fdb2bfe332e25fa1452ab8885
BLAKE2b-256 3b39d84ab65f9ce66c1198c884b8175bea7b69d7fb47db3fd0b33c50583cda03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tremolo_session-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9a9644c01e352081c7be5e0f2026a83c7dedf7c8950a88ae7e4c490ce72900a6
MD5 7213373632eb01f7d6e62e6fa6bf02ff
BLAKE2b-256 426e1c094ba9b30e0369d8062fe25136d226507d985f703ccf5dd675bd331243

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