Created
April 24, 2016 19:27
-
-
Save pgjones/74e95ddf35efc3bff106f26d36638b99 to your computer and use it in GitHub Desktop.
A replacement flask response to automatically jsonify dicts use with app.response_class = JSONResponse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import jsonify, Response | |
class JSONResponse(Response): | |
@classmethod | |
def force_type(cls, value, environ=None): | |
if isinstance(value, dict): | |
value = jsonify(value) | |
return super().force_type(value, environ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment