diff --git a/soundboard.py b/soundboard.py index 00e8237..8d789fc 100644 --- a/soundboard.py +++ b/soundboard.py @@ -178,3 +178,21 @@ WHERE button.id IN ( sounds = queryDB(query, tags.split(",")) return jsonify([sound["file"].split(".")[0] for sound in sounds]) + +@app.route("/tags/add/", methods=["GET", "POST"]) +def tags_add(): + if request.method == "POST": + if not request.form.get("cancel") and request.form.get("tag") is not None: + queryDB("INSERT OR REPLACE INTO tag (name) VALUES (?)", (request.form.get("tag"),)) + getDB().commit() + + return redirect("/edit") + + return render_template("tags_add.html") + +@app.route("/tags/delete/") +def tags_delete(name): + queryDB("DELETE FROM tag WHERE name = ?", (name,)) + getDB().commit() + + return redirect("/edit") diff --git a/templates/index.html b/templates/index.html index 168cc9f..751c268 100644 --- a/templates/index.html +++ b/templates/index.html @@ -47,8 +47,9 @@