diff --git a/exquisite_branch/api.py b/exquisite_branch/api.py index 2279832..bfaf315 100644 --- a/exquisite_branch/api.py +++ b/exquisite_branch/api.py @@ -20,10 +20,12 @@ def makeTree(entries): def list(): db = get_db() trees = db.execute('SELECT * FROM trees').fetchall() - response = [] + t = [] for tree in trees: - response.append(tree['slug']) - return jsonify(response) + t.append(tree['slug']) + response = jsonify(t) + response.headers.add("Access-Control-Allow-Origin", "*") + return response @bp.route('tree//') @@ -36,7 +38,7 @@ def tree(tree=None): (tree,) ).fetchall() - response = { + r = { "id": tree_info['id'], "slug": tree_info['slug'], "name": tree_info['name'], @@ -53,7 +55,9 @@ def tree(tree=None): # insert it in its parent if not NEW # remove it from the list - response['branches'] = makeTree(branches) + r['branches'] = makeTree(branches) + response = jsonify(r) + response.headers.add("Access-Control-Allow-Origin", "*") - return jsonify(response) + return response