diff --git a/app.py b/app.py index c0d0534..99ed3fa 100644 --- a/app.py +++ b/app.py @@ -22,6 +22,34 @@ except Exception as e: print("MongoDB connection error:", e) +@app.route("/") +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__":