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.12.tar.gz (4.5 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.12-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tremolo_session-1.0.12.tar.gz
  • Upload date:
  • Size: 4.5 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.12.tar.gz
Algorithm Hash digest
SHA256 8934ce574a9aac577f609cd0bc7031f891e382b48bdeb54d0cfd5c3207a0f099
MD5 70f710542cefac56fd12649f3cdfb38f
BLAKE2b-256 b5efc42d3a4986b986536f7d2fa8294d3dc17e3eb73e11fdcb142e16908d52d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tremolo_session-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 1f8400705c3b03526ea0e9b0308ce7eed22238f2214e12b5d78c66af52a23bf8
MD5 5b4cc08ca7518083c4056109ed30a74e
BLAKE2b-256 392dba40b3bef7eced4ea8b08a06275e3253fa4080509bc56d2edd81f35281c3

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