Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

replacing json.dumps with flask jsonify helper wrapper #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daghan
Copy link

@daghan daghan commented Jan 2, 2020

Hi Alex,

We have a free program analysis tool for Python based web projects, called Bento. While we were scanning GitHub projects for issues, your project triggered a warning for using json.dumps() instead of flask jsonify().

According to this Stackoverflow article (https://stackoverflow.com/questions/7907596/json-dumps-vs-flask-jsonify), the jsonify() function in flask returns a flask.Response() object that already has the appropriate content-type header 'application/json' for use with json responses. It also has support for handling multiple args / kwargs, including lists. Hopefully, you'll find this PR useful.

Bento flagged 2 other issues related to unsafe loading of yaml files and possible Python3 compatibility problem in griddata.py:149, but I didn't want to touch those issues in this PR. If you are interested, feel free download and give Bento a try (https://bento.dev).

@alex-leonhardt
Copy link
Owner

Thanks @daghan !

I haven't had time to test this, did you run it using jsonify()?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants