From 3ffec65000dbc74b0af458f33b8738b162dbd956 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 2 Jul 2024 17:08:53 -0700 Subject: [PATCH] add get all templates function --- server/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/app.py b/server/app.py index bcd90d8..7574af1 100644 --- a/server/app.py +++ b/server/app.py @@ -382,6 +382,23 @@ def get_template_cards(board_id): return jsonify(template_cards_list) +@app.route('/api/templates', methods=['GET']) +def get_templates(): + templates = Template.query.all() + templates_list = [] + + for template in templates: + template_data = { + 'uuid': template.uuid, + 'name': template.name, + 'author': template.author, + 'downloads': template.downloads, + 'uploaded_at': template.uploaded_at + } + templates_list.append(template_data) + + return jsonify(templates_list) + if __name__ == '__main__': with app.app_context(): db.create_all()