headers for cors

main
km0 2 years ago
parent b37d5c6d65
commit 7db1193cf7

@ -20,10 +20,12 @@ def makeTree(entries):
def list(): def list():
db = get_db() db = get_db()
trees = db.execute('SELECT * FROM trees').fetchall() trees = db.execute('SELECT * FROM trees').fetchall()
response = [] t = []
for tree in trees: for tree in trees:
response.append(tree['slug']) t.append(tree['slug'])
return jsonify(response) response = jsonify(t)
response.headers.add("Access-Control-Allow-Origin", "*")
return response
@bp.route('tree/<tree>/') @bp.route('tree/<tree>/')
@ -36,7 +38,7 @@ def tree(tree=None):
(tree,) (tree,)
).fetchall() ).fetchall()
response = { r = {
"id": tree_info['id'], "id": tree_info['id'],
"slug": tree_info['slug'], "slug": tree_info['slug'],
"name": tree_info['name'], "name": tree_info['name'],
@ -53,7 +55,9 @@ def tree(tree=None):
# insert it in its parent if not NEW # insert it in its parent if not NEW
# remove it from the list # 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

Loading…
Cancel
Save