tremolo-session
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
Release files for tremolo-session 1.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tremolo_session-1.0.13.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tremolo_session-1.0.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / tremolo_session-1.0.13.tar.gz
| Download URL | tremolo_session-1.0.13.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e06482c1e29e29120025f46b2526f3f403eb7edd35535d484d4971109cb887a
|
|
BLAKE2b-256 checksum How to use checksums |
43ff388571536bd3346621d2d5f6e1fe68f5690b94ca4ad35967f0eb58fb2dac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.11
|
Release files / tremolo_session-1.0.13-py3-none-any.whl
| Download URL | tremolo_session-1.0.13-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8458ee762a008219afd39feb0c68fca0489f4cfecdf6c2ab93be8d37099c502
|
|
BLAKE2b-256 checksum How to use checksums |
3bdfafd7fec3879b854bfcb40096f057f310175ebe56f25e8366d676334d5ba1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.11
|