"""Utilities to deal with requests.""" import werkzeug from flask import request def request_json() -> dict: """Retrieve the JSON sent in a request.""" if request.headers.get("Content-Type") == "application/json": # KLUDGE: We have this check here since request.json has the # type Any | None; see: # return request.json or {} else: return dict(request.args) or dict(request.form) or {}