Redis Sesion Implementation for Python Simple Http Server
What's this?
This is the redis session implementation for the project https://github.com/keijack/python-simple-http-server, use this extention to save you session data to redis.
How to use?
import simple_http_server
import simple_http_server.server as server
import os
from simple_http_server_redis_session.http_session_redis_impl import RedisSessionFactory
def main(*args):
# host, port, db, username, password are all optional.
simple_http_server.set_session_factory(RedisSessionFactory(host="10.0.2.16", port=6379, db=0, username="", password=""))
server.scan("tests/ctrls", r'.*controllers.*')
root = os.path.dirname(os.path.abspath(__file__))
server.start(
port=9090,
resources={"/public/*": f"{root}/tests/static"})
or you can re-use your redis client which might be used in other codes.
import simple_http_server
import simple_http_server.server as server
import os
import redis
from simple_http_server_redis_session.http_session_redis_impl import RedisSessionFactory
def main(*args):
# This redis client can be used in other business codes.
redis_client = redis.Redis(host="10.0.2.16", port=6379, db=0, username="", password="")
simple_http_server.set_session_factory(RedisSessionFactory(redis_client=redis_client))
root = os.path.dirname(os.path.abspath(__file__))
server.start(
port=9090,
resources={"/public/*": f"{root}/tests/static"})
Write Your Own ObjectSerializer
Module pickle is used to do the serialization and deserialization, if the defalut serialization logic could not satisfy you, you can write your own
simple_http_server_redis_session.http_session_redis_impl import ObjectSerializer
class MyObjectSerializer(ObjectSerializer):
def object_to_bytes(self, obj: Any) -> bytes:
bys = ...
return bys
def bytes_to_objects(self, value: bytes) -> Any:
obj = ...
return obj
# Set it when initializing a SessionFactory.
simple_http_server.set_session_factory(RedisSessionFactory(host="10.0.2.16", port=6379, db=0, username="", password="", object_serializer=MyObjectSerializer()))
Metadata
Release files for simple-http-server-redis-session 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_http_server_redis_session-0.3.0.tar.gz | 4.1 kB | Without provenance | Details for simple_http_server_redis_session-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_http_server_redis_session-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for simple_http_server_redis_session-0.3.0-py3-none-any.whl |
Total release size: 10.0 kB
Release files / simple_http_server_redis_session-0.3.0.tar.gz
| Download URL | simple_http_server_redis_session-0.3.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55abc21e67fe4841d4ef14c7fb646eeb15bbd32eb09ab1e45e81e7e179a3de85
|
|
BLAKE2b-256 checksum How to use checksums |
82cacb242c7105ba76ca53d6eda45d69af9cea6a431fe80d04ccb0508ad0810b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / simple_http_server_redis_session-0.3.0-py3-none-any.whl
| Download URL | simple_http_server_redis_session-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a77db935907a2a3cd1c752ba501ae67c2b2a12117153581d9e74f5d5dcdd397
|
|
BLAKE2b-256 checksum How to use checksums |
960ceaacdf3fd755b5f034e83647752ea082c0eb22640ba5a28eadc0d6a98d25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for simple-http-server-redis-session 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.