From 5c757e4be645878b7963c2d07eb4442204b90653 Mon Sep 17 00:00:00 2001 From: Girish Raghav Date: Mon, 19 Feb 2024 19:49:57 +0530 Subject: [PATCH] Fixed Get method --- apps/flask/main.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/flask/main.py b/apps/flask/main.py index 5982825..e593ece 100644 --- a/apps/flask/main.py +++ b/apps/flask/main.py @@ -85,7 +85,7 @@ def add_data_to_firestore(collection_name, key, data): doc_ref.set(current_data) -@app.route('/api/v1/',methods = ['POST']) +@app.route('/api/post/',methods = ['POST']) def add_details(): try: data = request.get_json() @@ -106,22 +106,14 @@ def add_details(): def get_data_from_firestore(): doc_ref = db.collection('needs_and_gives') docs = doc_ref.stream() - data_dict = {"need": [], "give": []} + data_list = [] for doc in docs: - doc_data = doc.to_dict() - if "need" in doc_data: - data_dict["need"].append(doc_data["need"]) - if "give" in doc_data: - data_dict["give"].append(doc_data["give"]) - - return jsonify(data_dict), 200 - + data_list.append(doc.to_dict()) # Accessing dictionaries by index result = {"need":data_list[1]["need"],"give":data_list[0]["give"]} return result,200 -