Flask with UltraJSON.
Project description
flask-orjson
pip install flask-orjson
Flask with orjson.
from flask import Flask, request
from flask_orjson import ORJSON
orjson = ORJSON()
def create_app():
app = Flask(__name__)
orjson.init_app(app) # Sets ORJSON as the default JSON encoder
@app.route("/")
def index():
"""
Outputs a JSON response using the orjson library
https://github.com/ijl/orjson
"""
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)
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_orjson-1.0.1.tar.gz
(11.4 kB
view details)
Built Distribution
File details
Details for the file flask_orjson-1.0.1.tar.gz
.
File metadata
- Download URL: flask_orjson-1.0.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | effc0ff6f6687f8082bd350bf1ffb1992d66849fe7dc9cd0a65352ffbdddf105 |
|
MD5 | a26ef5f898da13c71d1300ccb7dc6e1b |
|
BLAKE2b-256 | 7285a3922872541c88bc538ece831d1d9a35391992b390e8944b6decd08706f9 |
File details
Details for the file flask_orjson-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: flask_orjson-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cc50618ae49b07e733a830d0d3405663c67bb7dd07a0f84b7165797819c439d |
|
MD5 | 9366a1841e012e90e2dae66b3e3864e8 |
|
BLAKE2b-256 | c22f5a042e608f5095a58e18b6ac799903fd1ceed091083d14ece89ec52a0c3c |