1
0
mirror of https://git.ikl.sh/132ikl/liteshort.git synced 2023-08-10 21:13:04 +03:00

Fix non-API returning HTML despite Accept header

This commit is contained in:
132ikl 2020-04-12 04:59:12 -04:00
parent 1062b71334
commit fbb9a30eae

View File

@ -135,12 +135,11 @@ def nested_list_to_dict(l):
def response(rq, result, error_msg="Error: Unknown error"): def response(rq, result, error_msg="Error: Unknown error"):
if rq.form.get("api"): if rq.accept_mimetypes.accept_json and not rq.accept_mimetypes.accept_html:
if rq.accept_mimetypes.accept_json:
if result: if result:
return flask.jsonify(success=bool(result), result=result) return flask.jsonify(success=bool(result), result=result)
return flask.jsonify(success=bool(result), message=error_msg) return flask.jsonify(success=bool(result), message=error_msg)
else: if rq.form.get("api"):
return "Format type HTML (default) not supported for API" # Future-proof for non-json return types return "Format type HTML (default) not supported for API" # Future-proof for non-json return types
else: else:
if result and result is not True: if result and result is not True: