Aggiunta pagina handling form delete
This commit is contained in:
14
app.py
14
app.py
@@ -54,7 +54,7 @@ def web_ui():
|
|||||||
html = "<table border>"
|
html = "<table border>"
|
||||||
for ciscomerda in compiti:
|
for ciscomerda in compiti:
|
||||||
html += "<tr>"
|
html += "<tr>"
|
||||||
html += f"<td>{ciscomerda["descrizione"]}</td><td><a href=\"/form_delete\" class=\"button\">Elimina</a>"
|
html += f"<td>{ciscomerda["descrizione"]}</td><td><a href=\"/form_delete?id={ciscomerda["id"]}\" class=\"button\">Elimina</a>"
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
html += "</table>"
|
html += "</table>"
|
||||||
|
|
||||||
@@ -76,4 +76,16 @@ def form_add():
|
|||||||
id_counter += 1
|
id_counter += 1
|
||||||
return redirect("/ui")
|
return redirect("/ui")
|
||||||
|
|
||||||
|
@app.route("/form_delete")
|
||||||
|
def form_delete():
|
||||||
|
if not request.args.get("id"):
|
||||||
|
return "Errore: id mancante", 400
|
||||||
|
else:
|
||||||
|
id = int(request.args.get("id"))
|
||||||
|
for ciscomerda in compiti:
|
||||||
|
if ciscomerda["id"] == id:
|
||||||
|
compiti.remove(ciscomerda)
|
||||||
|
return redirect("/ui")
|
||||||
|
return "Errore: compito non trovato", 404
|
||||||
|
|
||||||
app.run("0.0.0.0")
|
app.run("0.0.0.0")
|
||||||
|
|||||||
Reference in New Issue
Block a user