This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/utils/flask_utils.py

17 lines
392 B
Python
Raw Normal View History

2021-07-26 18:23:32 +02:00
import json
def get_data_in_request(request):
data_str = str(request.data.decode('utf8')).replace('"', '\"').replace("\'", "'")
# if no data return an empty json to avoid error with json.loads below
if not data_str:
return {}
data_json = json.loads(data_str)
if not isinstance(data_json, dict):
data_json = json.loads(data_json)
return data_json