def product_list(): keyword = request.args["keyword"] if request.args.get("keyword") else None from_price = float(request.args["from_price"]) if request.args.get("from_price") else None to_price = float(request.args["to_price"]) if request.args.get("to_price") else None return render_template("product-list.html", products=dao.read_products(keyword=keyword, from_price=from_price, to_price=to_price))
def export(): products = dao.read_products() p = os.path.join(app.root_path, "data/products.csv") with open(p, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=[ "id", "name", "description", "price", "image", "category_id" ]) writer.writeheader() for pro in products: writer.writerow(pro) return p
def index(): return render_template("index.html", products=dao.read_products())
def product_list(): keyword = request.args["keyword"] if request.args.get("keyword") else None return render_template("product-list.html", products=dao.read_products(keyword=keyword))
def index(): return render_template("index.html", products=dao.read_products(), latest_products=dao.read_products(is_latest=True))