"""Utilities to deal with requests.""" import werkzeug from flask import request def request_json() -> dict: """Retrieve the JSON sent in a request.""" try: json_data = request.json # KLUDGE: We have this check here since request.json has the # type Any | None; see: # return json_data if isinstance(json_data, dict) else {} except werkzeug.exceptions.UnsupportedMediaType: return dict(request.form) or {}