Pre-release
This release is a pre-release and may not be stable for production use.
bareASGI-session
Session support for bareASGI (read the docs).
Usage
You can add session middleware with the add_session_middleware helper function.
from bareasgi import Application
from bareasgi_session import (
add_session_middleware,
MemorySessionStorage
)
app = Application()
add_session_middleware(app, MemorySessionStorage())
The session can be retrieved with the session_data helper function. This returns
an (initially empty) dictionary.
from datetime import datetime
from bareutils import text_writer
from bareasgi_session import session_data
async def session_handler(request: HttpRequest) -> HttpResponse:
session = session_data(request)
now = session.get('now')
message = f'The time was {now}' if now else 'First time'
session['now'] = datetime.now()
headers: List[Header] = [
(b'content-type', b'text/plain'),
(b'content-length', str(len(message)).encode('ascii'))
]
return HttpResponse(200, headers, text_writer(message))
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 bareASGI-session-4.0.0a0.tar.gz.
File metadata
- Download URL: bareASGI-session-4.0.0a0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.8 CPython/3.9.6 Darwin/19.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca1c9b319b58da9e060fc4c7dd1e172e79e4169c2a877f351fb5f576e129a72
|
|
| MD5 |
ba5104ec574877f3329e1c513db54634
|
|
| BLAKE2b-256 |
24ab4eb32043941ad2e31ae8606e0b1160f833b825f8f6eb75c1845010db243b
|
File details
Details for the file bareASGI_session-4.0.0a0-py3-none-any.whl.
File metadata
- Download URL: bareASGI_session-4.0.0a0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.8 CPython/3.9.6 Darwin/19.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10964e03a528ac342f2781ae18fa318b4db07bfb65faafc8a74ef90c284939fe
|
|
| MD5 |
d46304af1f1303d01935d2d1aa1260cb
|
|
| BLAKE2b-256 |
7a01c72701282bfc40f78b3971b12d7b56d56bcc8cdb67b3e7ea69f4e29a3618
|