Exemple #1
0
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))
Exemple #2
0
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
Exemple #3
0
def index():
    return render_template("index.html", products=dao.read_products())
Exemple #4
0
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))
Exemple #5
0
def index():
    return render_template("index.html",
                           products=dao.read_products(),
                           latest_products=dao.read_products(is_latest=True))