diff --git a/app.py b/app.py index 138bcee..903c3bb 100644 --- a/app.py +++ b/app.py @@ -87,16 +87,12 @@ def zeit(sekunden): @app.route("/") def hello_world(): liste = request.args.get("liste") - print("/") - print(liste) if liste is None: return redirect("/playlists") - print(liste) with open(liste+".json","r") as f: songs = json.load(f) for song in songs: kartenGeneriren(song) - print(songs) gesamtLaenge = 0 for song in songs: gesamtLaenge += song["laenge"] @@ -107,15 +103,11 @@ def hello_world(): def playlists(): listen = glob("*.json") listen = (liste.replace(".json","") for liste in listen) - print("/playlists") - print(listen) return render_template('playlists.html',lists=listen) @app.route("/neueliste") def neueliste(): name = request.args.get("name") - print("/neueliste") - print(name) if name is not None: with open(name +".json", "x") as f: json.dump([],f) @@ -127,8 +119,6 @@ def neueliste(): def suche(): such = request.args.get("suche") liste = request.args.get("liste") - print("/suche") - print(liste) if such is not None: ergebnisse = wikisuche(such) else: @@ -143,22 +133,34 @@ def suche_finden(): song = {"wikiid":request.form.get("id")} kartenGeneriren(song) songs.append(song) - print(liste) with open(liste+".json","w") as f: json.dump(songs,f,indent=2,ensure_ascii=False) return redirect("/suche?liste="+liste,303) -@app.route("/ADMIN") +@app.route("/rm") def admin(): + liste = request.args.get("liste") + if liste is None: + return redirect("/playlists") + with open(liste+".json","r") as f: + songs = json.load(f) + for song in songs: + kartenGeneriren(song) gesamtLaenge = 0 for song in songs: gesamtLaenge += song["laenge"] - return render_template('index.html', karten=songs,gesamtLaenge=gesamtLaenge,admin=True ) + return render_template('index.html', karten=songs,gesamtLaenge=gesamtLaenge,liste=liste,admin=True) -@app.route("/ADMIN",methods=["POST"]) +@app.route("/rm",methods=["POST"]) def loeschen(): + liste = request.args.get("liste") song = int(request.form.get("index")) + with open(liste+".json","r") as f: + print(liste+".json") + songs = json.load(f) + print(songs) + print(songs) del songs[song] - with open("songs.json","w") as f: + with open(liste+".json","w") as f: json.dump(songs,f,indent=2,ensure_ascii=False) - return redirect("/ADMIN",303) \ No newline at end of file + return redirect("/rm?liste="+liste,303) \ No newline at end of file diff --git a/templates/suche.html b/templates/suche.html index 1e1e182..7673f1a 100644 --- a/templates/suche.html +++ b/templates/suche.html @@ -12,7 +12,7 @@ {% if ergebnisse %}
{%elif anfrage%}