From b0181c147082c2e3dfd0f5c135462339ecf02cbb Mon Sep 17 00:00:00 2001 From: al6862 Date: Sat, 24 Feb 2024 22:46:09 -0500 Subject: [PATCH] added edit card route --- app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app.py b/app.py index 99ed3fa..343ef7c 100644 --- a/app.py +++ b/app.py @@ -51,6 +51,16 @@ def addCard(username, deckTitle): # would redirect to template for Cards return "added card" +@app.route("////edit", methods=["POST"]) +def editCard(username, deckTitle, cardIndex): + # 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"][int(cardIndex)] = newCard + db.decks.update_one({"title": deckTitle}, {"$set": deck}) + # would redirect to template for Cards + return "edited card" + # run the app if __name__ == "__main__": FLASK_PORT = os.getenv("FLASK_PORT", "5000")