Make jsonify terminate responses with a newline
This came up in the context of https://github.com/kennethreitz/httpbin/issues/168
This commit is contained in:
parent
b24438b2c9
commit
d9402fc0c0
3 changed files with 17 additions and 8 deletions
|
|
@ -200,8 +200,9 @@ def htmlsafe_dump(obj, fp, **kwargs):
|
|||
|
||||
def jsonify(*args, **kwargs):
|
||||
"""Creates a :class:`~flask.Response` with the JSON representation of
|
||||
the given arguments with an :mimetype:`application/json` mimetype. The arguments
|
||||
to this function are the same as to the :class:`dict` constructor.
|
||||
the given arguments with an :mimetype:`application/json` mimetype. The
|
||||
arguments to this function are the same as to the :class:`dict`
|
||||
constructor.
|
||||
|
||||
Example usage::
|
||||
|
||||
|
|
@ -241,9 +242,13 @@ def jsonify(*args, **kwargs):
|
|||
indent = 2
|
||||
separators = (', ', ': ')
|
||||
|
||||
return current_app.response_class(dumps(dict(*args, **kwargs),
|
||||
indent=indent, separators=separators),
|
||||
# Note that we add '\n' to end of response
|
||||
# (see https://github.com/mitsuhiko/flask/pull/1262)
|
||||
rv = current_app.response_class(
|
||||
(dumps(dict(*args, **kwargs), indent=indent, separators=separators),
|
||||
'\n'),
|
||||
mimetype='application/json')
|
||||
return rv
|
||||
|
||||
|
||||
def tojson_filter(obj, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue