Example #1
0
def json_resp_from_thing(thing):
    my_dict = util.todict(thing)
    json_str = json.dumps(my_dict, sort_keys=True, indent=4)

    if request.path.endswith(".json") and (os.getenv("FLASK_DEBUG", False) == "True"):
        logger.info(u"rendering output through debug_api.html template")
        resp = make_response(render_template(
            'debug_api.html',
            data=json_str))
        resp.mimetype = "text/html"
        return views_helpers.bust_caches(resp)

    resp = make_response(json_str, 200)
    resp.mimetype = "application/json"
    return views_helpers.bust_caches(resp)
Example #2
0
def json_resp_from_thing(thing):

    my_dict = util.todict(thing)
    json_str = json.dumps(my_dict, sort_keys=True, indent=4)
    resp = make_response(json_str, 200)
    resp.mimetype = "application/json"
    return views_helpers.bust_caches(resp)
Example #3
0
def json_resp_from_thing(thing):

    my_dict = util.todict(thing)
    json_str = json.dumps(my_dict, sort_keys=True, indent=4)
    resp = make_response(json_str, 200)
    resp.mimetype = "application/json"
    return views_helpers.bust_caches(resp)
Example #4
0
def json_resp_from_jsonable_thing(jsonable_thing):
    json_str = json.dumps(jsonable_thing, sort_keys=True, indent=4)
    resp = make_response(json_str, 200)
    resp.mimetype = "application/json"
    return views_helpers.bust_caches(resp)