WMGZON/controllers/web/product.py

30 lines
818 B
Python

from flask import Blueprint
from flask import render_template, request, session, flash
from controllers.database.product import ProductController
blueprint = Blueprint("products", __name__, url_prefix="/products")
# Loads the front product page
@blueprint.route('/')
def index():
database = ProductController()
products = database.read_all()
# No Products visible
if products == None:
flash("No Products available")
return render_template('index.html', content="content.html", user = session.get('user'), products = products)
# Loads a given product category page
@blueprint.route('/<string:category>')
def category(category: str):
return "Category: " + category
# Loads a given product based on ID
@blueprint.route('/<int:id>')
def id(id: int):
return "ID: " + str(id)