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 '.'.

Installation

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

Encode

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

Decode

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

Test Coverage

Name                                         Stmts   Miss  Cover
----------------------------------------------------------------
src/__init__.py                                  0      0   100%
src/web_encoder/__init__.py                      4      0   100%
src/web_encoder/exceptions.py                   34      0   100%
src/web_encoder/main.py                         82      0   100%
tests/__init__.py                                0      0   100%
tests/unit/__init__.py                           0      0   100%
tests/unit/web_encoder/__init__.py               0      0   100%
tests/unit/web_encoder/test_web_encoder.py     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 Python 3

Supported by

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