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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tremolo-session-1.0.11.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.11.tar.gz
Algorithm Hash digest
SHA256 90270cb45cd37bbdab599637aa70ba8583a1ab1198d482955df807ff5ee166ce
MD5 37792f7826e706735f0fdd849e9b5818
BLAKE2b-256 da19f1506d6c4b308ed350fa9c2eeac8de373d8952478bac306645b23229c6d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tremolo_session-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9d36cc50b577a1d0aaad963d5841b7798b60c7ac7ad65587738e0b13b48735
MD5 14590695ddf3c988c0bca8af6451fc73
BLAKE2b-256 08ad1223cdee567a094dd68a98aa9eff711a30ae41c6706d50e48f5bbcc516ca

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