Skip to main content

Flask with UltraJSON.

Project description

flask-ujson

PyPI version License

pip install flask-ujson

Flask with UltraJSON.

https://github.com/ultrajson/ultrajson

from flask import Flask, jsonify

from flask_ujson import UJSON

ultra_json = UJSON()


def create_app():
    app = Flask(__name__)
    ultra_json.init_app(app)  # Replaces the standard JSON encoder with UltraJSON

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

        https://github.com/ultrajson/ultrajson
        """
        return {"hello": "world"}

    @app.route("/jsonify")
    def using_jsonify():
        """
        jsonify is not really needed for most cases, but here's an example.
        """
        return jsonify({"hello": "world"})

    return app


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

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

flask_ujson-1.0.4.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

flask_ujson-1.0.4-py3-none-any.whl (11.7 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