A simple, file-based session middleware for Tremolo.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8934ce574a9aac577f609cd0bc7031f891e382b48bdeb54d0cfd5c3207a0f099
|
|
| MD5 |
70f710542cefac56fd12649f3cdfb38f
|
|
| BLAKE2b-256 |
b5efc42d3a4986b986536f7d2fa8294d3dc17e3eb73e11fdcb142e16908d52d4
|
File details
Details for the file tremolo_session-1.0.12-py3-none-any.whl.
File metadata
- Download URL: tremolo_session-1.0.12-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f8400705c3b03526ea0e9b0308ce7eed22238f2214e12b5d78c66af52a23bf8
|
|
| MD5 |
5b4cc08ca7518083c4056109ed30a74e
|
|
| BLAKE2b-256 |
392dba40b3bef7eced4ea8b08a06275e3253fa4080509bc56d2edd81f35281c3
|