master
Matt Huntington 3 years ago
parent b396cbdaea
commit de1cf9d15a

@ -39,3 +39,8 @@ def show(id):
parent=cursor.fetchone()
cursor.execute('SELECT * FROM items WHERE parent_id=%s',[id])
return render_template('show.html', parent=parent, cursor=cursor)
@app.get('/<id>/edit')
def edit(id):
cursor.execute('SELECT * FROM items WHERE id=%s', [id])
return render_template('edit.html', item=cursor.fetchone())

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<section>
<h2>Edit {{item[1]}}</h2>
<form action="/{{item[0]}}?_method=PUT" method="POST">
<input name="title" type="text" value="{{item[1]}}">
<textarea name="description">{{item[2]}}</textarea>
<input type="number" name="parent_id" value="{{item[5]}}"/>
<input type="submit"/>
</form>
</section>
<section>
<a href="/">To Index</a>
</section>
</body>
</html>

@ -36,7 +36,12 @@
</form>
</section>
<section>
<a href="/">To Index</a>
<nav>
<ul>
<li><a href="/">To Index</a></li>
<li><a href="/{{parent[0]}}/edit">Edit</a></li>
</ul>
</nav>
</section>
</body>
</html>

Loading…
Cancel
Save