(20241203) Minor upgrades.

This commit is contained in:
2024-12-03 15:44:35 +05:30
parent 615d8c71a5
commit 3b5a1fc92f
8 changed files with 792 additions and 727 deletions
+7 -2
View File
@@ -136,17 +136,22 @@ class AuthDetailsIncompleteException(Exception):
# *****************************************************************************************************************
async def make_ordered_json(json_data, http_code = 200):
async def make_ordered_json(
json_data,
no_space = True,
http_code = 200
):
"""
Quart sorts the fields of a dict when converting to a JSON response. Here we are manually making the response when
the sequence of the fields is sensitive.
:param json_data: The data (dict, list, etc.) to be converted to a JSON string.
:param no_space: Set this to True to remove all excess white spaces from the JSON string. Saves bandwidth.
:param http_code: The HTTP status code you want to send with the response.
:return: The JSON-ified response such that the sequence of the fields is maintained.
"""
response = await make_response(json.to_string(json_data, no_space = True), http_code)
response = await make_response(json.to_string(json_data, no_space = no_space), http_code)
response.headers["Content-Type"] = "application/json"
return response