From 3e6ee099757da84640591c9fd84741eb8add829b Mon Sep 17 00:00:00 2001 From: al6862 Date: Sat, 24 Feb 2024 15:44:28 -0500 Subject: [PATCH 1/2] added home route --- app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.py b/app.py index c0d0534..2ac048c 100644 --- a/app.py +++ b/app.py @@ -22,6 +22,9 @@ except Exception as e: print("MongoDB connection error:", e) +@app.route("/") +def home(): + return render_template('mainScreen.html') # run the app if __name__ == "__main__": From 67b3a18343739e317dabcb477b03a61cd34a1768 Mon Sep 17 00:00:00 2001 From: al6862 Date: Sat, 24 Feb 2024 17:29:46 -0500 Subject: [PATCH 2/2] added routes to view all decks, to create a new deck, to add new card to existing deck --- app.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app.py b/app.py index 2ac048c..99ed3fa 100644 --- a/app.py +++ b/app.py @@ -26,6 +26,31 @@ def home(): return render_template('mainScreen.html') +@app.route("//decks") +def allDecks(username): + # would need to first find user in db, but not set up yet + # would redirect to template for Decks + return f'{username} decks' + +@app.route("//create", methods=["POST"]) +def createDeck(username): + # would need to first find user in db, but not set up yet + title = request.form["title"] + newDeck = {"title": title, "cards": []} + db.decks.insert_one(newDeck) + # would rendirect to template for Cards + return "created deck" + +@app.route("///add", methods=["POST"]) +def addCard(username, deckTitle): + # would need to first find user in db, but not set up yet + deck = db.decks.find_one({"title": deckTitle}) + newCard = request.form["question"] + deck["cards"].append(newCard) + db.decks.update_one({"title": deckTitle}, {"$set": deck}) + # would redirect to template for Cards + return "added card" + # run the app if __name__ == "__main__": FLASK_PORT = os.getenv("FLASK_PORT", "5000")