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,13 +135,12 @@ def nested_list_to_dict(l):
def response(rq, result, error_msg="Error: Unknown error"):
if rq.accept_mimetypes.accept_json and not rq.accept_mimetypes.accept_html:
if result:
return flask.jsonify(success=bool(result), result=result)
return flask.jsonify(success=bool(result), message=error_msg)
if rq.form.get("api"):
if rq.accept_mimetypes.accept_json:
if result:
return flask.jsonify(success=bool(result), result=result)
return flask.jsonify(success=bool(result), message=error_msg)
else:
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:
if result and result is not True:
flask.flash(result, "success")