Skip to main content

Used to encode or decode data in a web-friendly format.

Project description

Web Encoder

Used to encode and decode data in a web-friendly format.

It's only uses building libraries, therefore, it has no external dependency. It is also lightweight and thread-safe, which makes it ideal for use in services and microservices.

By default WebEncoder will try to compress the data. If it manages to compress the data, the encoded data started with '.'.


pip install Web-Encoder

Typical usage example:

Encode session

web_encoder = WebEncoder()

session_id = "b801692b-135f-40ff-8f7e-016dc7748c45"
session = {"user_uuid": "67fa3e17-4672-4036-8184-7fbe4c097439"}
encoded_session = web_encoder.encode(json.dumps(session))

redis.set(session_id, encoded_session)

Decode session

web_encoder = WebEncoder()

session_id = "b801692b-135f-40ff-8f7e-016dc7748c45"
encoded_session = redis.get(session_id)
session = json.loads(web_encoder.decode(encoded_session))

Run as module


user@host:~$ python3 -m web_encoder e 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'


user@host:~$ python3 -m web_encoder d 'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4'
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Test Coverage

Name                                         Stmts   Miss  Cover
src/                                  0      0   100%
src/web_encoder/                      4      0   100%
src/web_encoder/                   34      0   100%
src/web_encoder/                         82      0   100%
tests/                                0      0   100%
tests/unit/                           0      0   100%
tests/unit/web_encoder/               0      0   100%
tests/unit/web_encoder/     244      0   100%
TOTAL                                          364      0   100%

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

Web Encoder-0.1.2.tar.gz (5.9 kB view hashes)

Uploaded source

Built Distribution

Web_Encoder-0.1.2-py3-none-any.whl (7.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page