From 6b914bc9075867389b0cd322424c945b6a6e57bb Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Thu, 12 Jan 2023 22:46:15 -0500 Subject: [PATCH] delete --- server.py | 8 +++++++- templates/show.html | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 5a10906..f6f53c5 100644 --- a/server.py +++ b/server.py @@ -20,5 +20,11 @@ def show(): @app.post("/") def create(): - cursor.execute('INSERT INTO items (title, description) VALUES(?,?)', (request.form['title'],request.form['description'])) + cursor.execute('INSERT INTO items (title, description) VALUES(%s,%s)', (request.form['title'],request.form['description'])) + return redirect('/') + +@app.post("/") +def delete(id): + # print(request.args.get('_method')) + cursor.execute('DELETE FROM items WHERE id=%s LIMIT 1', [int(id)]) return redirect('/') diff --git a/templates/show.html b/templates/show.html index 83cab1c..0100341 100644 --- a/templates/show.html +++ b/templates/show.html @@ -10,6 +10,9 @@ {%for (id, title, description, created_at, updated_at, parent_id) in cursor%}
  • {{title}}: {{description}} +
    + +
  • {%endfor%}