Add flasktools.make_json_response.
This commit is contained in:
parent
ee8c4b7fd8
commit
663e65795a
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,7 @@ import flask
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
import gzip
|
||||||
import io
|
import io
|
||||||
|
import json
|
||||||
import werkzeug.wrappers
|
import werkzeug.wrappers
|
||||||
|
|
||||||
from voussoirkit import bytestring
|
from voussoirkit import bytestring
|
||||||
|
@ -59,3 +60,9 @@ def gzip_response(request, response):
|
||||||
response.headers['Content-Length'] = len(response.get_data())
|
response.headers['Content-Length'] = len(response.get_data())
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def make_json_response(j, *args, **kwargs):
|
||||||
|
dumped = json.dumps(j)
|
||||||
|
response = flask.Response(dumped, *args, **kwargs)
|
||||||
|
response.headers['Content-Type'] = 'application/json;charset=utf-8'
|
||||||
|
return response
|
||||||
|
|
Loading…
Reference in a new issue