Skip to main content

flask-ujson

PyPI version License

pip install flask-ujson

Flask with UltraJSON.

https://github.com/ultrajson/ultrajson

from flask import Flask, request

from flask_ujson import UJSON

ultra_json = UJSON()


def create_app():
    app = Flask(__name__)
    ultra_json.init_app(app)  # Sets UltraJSON as the default JSON encoder

    @app.route("/")
    def index():
        """
        Outputs a JSON response using UltraJSON library

        https://github.com/ultrajson/ultrajson
        """
        return {
            "timestamp": 1556283673.1523004,
            "task_uuid": "0ed1a1c3-050c-4fb9-9426-a7e72d0acfc7",
            "task_level": [1, 2, 1],
            "action_status": "started",
            "action_type": "main",
            "key": "value",
            "another_key": 123,
            "and_another": ["a", "b"],
        }

    @app.post("/post")
    def accept_json():
        json = request.get_json()
        return json

    return app


if __name__ == "__main__":
    app = create_app()
    app.run(debug=True)

Metadata

Release files for flask-ujson 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-ujson 1.0.6
File Size Uploaded
flask_ujson-1.0.6.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-ujson 1.0.6
File Interpreter ABI Platform
flask_ujson-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / flask_ujson-1.0.6.tar.gz

Download URL flask_ujson-1.0.6.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
85ee2d0e7832b22c9497a5d14152553ab51b29f20c24e5ac9e0bd1ae65443e2b
BLAKE2b-256 checksum
How to use checksums
25f4ac510d49392ee5830077624d2a77f1639c83a3d05fe91cb7444e9f783955
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / flask_ujson-1.0.6-py3-none-any.whl

Download URL flask_ujson-1.0.6-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2de50bf793746cfa37539653c21a0baba9f6027f04274372c49cee6354ae8e9
BLAKE2b-256 checksum
How to use checksums
0a4f3315cb20cbda2aa5a08a981b3c7e50cc6d1b171c2cbf704a4423c4db980e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page