#6 Added Database functionality for user to click and load a single item
This commit is contained in:
@ -64,6 +64,16 @@ def category(category: str):
|
||||
@blueprint.route('/<int:id>')
|
||||
def id(id: int):
|
||||
""" Loads a given product based on ID """
|
||||
db = ProductController()
|
||||
product = db.read_id(id)
|
||||
|
||||
# Check that a valid product was returned
|
||||
if product is None:
|
||||
flash("No Product available here")
|
||||
return redirect("/")
|
||||
|
||||
print(product.name)
|
||||
return render_template('index.html', content='content.html', products = [product])
|
||||
return "ID: " + str(id)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user