From d0194bf3e448f48f1a4a0ecf66d37519a4438121 Mon Sep 17 00:00:00 2001 From: Dana Truempy Date: Sun, 17 May 2020 20:22:36 -0500 Subject: [PATCH] Set up JSON endpoint for wishlist entries --- .gitignore | 6 ++++++ backend/app.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 backend/app.py diff --git a/.gitignore b/.gitignore index c4ac289..abd281a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,12 @@ backend/lib* backend/Scripts backend/pyvenv.cfg +# python +backend/__pycache__ + +# backend db +backend/db.sqlite + # dependencies frontend/node_modules frontend/.pnp diff --git a/backend/app.py b/backend/app.py new file mode 100644 index 0000000..7008ca2 --- /dev/null +++ b/backend/app.py @@ -0,0 +1,16 @@ +import sqlite3 +from flask import Flask, jsonify +app = Flask(__name__) + +@app.route('/wishlist//entries') +def entries(wishlist_id): + conn = sqlite3.connect('db.sqlite') + curs = conn.cursor() + + data = [] + for row in curs.execute( + 'SELECT WISHLIST_ID, ITEM_ID, NAME, DESCRIPTION FROM WISHLIST_ENTRY WHERE WISHLIST_ID = ?', + (wishlist_id,) + ): + data.append({'wishlist_id': row[0], 'item_id': row[1], 'name': row[2], 'description': row[3]}) + return jsonify(data) -- 2.20.1