Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
Fix non-API returning HTML despite Accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
132ikl committed Apr 12, 2020
1 parent 1062b71 commit fbb9a30
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions liteshort/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fbb9a30

Please sign in to comment.