def make_response(data, code, http_code=200): data = dict(error=dict(code=code.get('code'), http_code=http_code, description=code.get('description')), result=data) response = flask_make_response(json.dumps(data, indent=4), http_code) response.headers['Content-Type'] = 'application/json; charset=utf-8' return add_cross_domain_headers(response)
def make_response(*args, **kwargs): """ Customized flask-restful make_response """ response = flask_make_response(*args, **kwargs) if request.is_jsonapi: # Only use "application/vnd.api+json" if the client sent this with the request response.headers["Content-Type"] = "application/vnd.api+json" return response
def jsonify_status_code(status_code, *args, **kw): """Returns a jsonified response with the specified HTTP status code. The positional and keyword arguments are passed directly to the :func:`flask.jsonify` function which creates the response. """ is_batch = kw.pop('is_batch', False) if is_batch: response = flask_make_response(json.dumps(*args, **kw)) response.mimetype = 'application/json' response.status_code = status_code return response response = jsonify(*args, **kw) response.status_code = status_code return response
def intro(): resp = flask_make_response(render_template('index.html', intro=True)) resp.set_cookie('intro', '1') return resp
def make_response(message, status): response = flask_make_response(message, status) return response