diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -27,7 +27,7 @@ def load_data(): data = json.load(file) logging.info("Данные успешно загружены из JSON") if not isinstance(data, dict) or 'products' not in data or 'categories' not in data: - return {'products': [], 'categories': []} # Corrected: return empty dict with lists + return {'products': [], 'categories': []} return data except FileNotFoundError: logging.warning("Локальный файл базы данных не найден после скачивания.") @@ -94,7 +94,6 @@ def periodic_backup(): def catalog(): data = load_data() products = data['products'] - # categories = data['categories'] Removed categories from main page catalog_html = ''' @@ -102,12 +101,11 @@ def catalog(): - Канцелярия Оптом + Fire collection + + +
+
+
+ +

Fire collection

+
+ +
+
+ {% for category in categories %} + +

{{ category }}

+
+ {% endfor %} +
+
+ + + + + + + + + + ''' + return render_template_string(category_html, products=products, category=category, repo_id=REPO_ID) + +@app.route('/favorites') +def favorites_page(): + data = load_data() + favorites = JSON.parse(localStorage.getItem('favorites') || '[]') + products = [data['products'][int(i)] for i in favorites if int(i) < len(data['products'])] + + favorites_html = ''' + + + + + + Избранное - Fire collection + + + + + + +
+
+
+ +

Избранное

+
+ +
+
+ {% for product in products %} +
+ + {% if product.get('photos') and product['photos']|length > 0 %} +
+ {{ product['name'] }} +
+ {% endif %} + {% if product.get('discount') %} + Скидка {{ product['discount'] }}% + {% endif %} +

{{ product['name'] }}

+
+ {% if product.get('discount') %} + {{ (product['price'] * (1 - product['discount'] / 100))|round(2) }} с + Скидка: {{ product['discount'] }}% + {% else %} + {{ product['price'] }} с + {% endif %} +
+

{{ product['description'][:50] }}{% if product['description']|length > 50 %}...{% endif %}

+ +
+ {% endfor %} +
+
+ + + + + + + + + + + + + + + + + + ''' + return render_template_string(favorites_html, products=products, repo_id=REPO_ID) + +@app.route('/discounts') +def discounts_page(): + data = load_data() + products = [p for p in data['products'] if p.get('discount')] + + discounts_html = ''' + + + + + + Скидки - Fire collection + + + +
-

Админ Панель

- -
-
-

Продукты

- +
+ +

Скидки

+
+
-
- -

- -

-

Цена:

-

Категория:

-

Цвета:

-
-

Связанные товары:

-
+
+ {% for product in products %} +
+ + {% if product.get('photos') and product['photos']|length > 0 %} +
+ {{ product['name'] }} +
+ {% endif %} + Скидка {{ product['discount'] }}% +

{{ product['name'] }}

+
+ {{ (product['price'] * (1 - product['discount'] / 100))|round(2) }} с + Скидка: {{ product['discount'] }}%
+

{{ product['description'][:50] }}{% if product['description']|length > 50 %}...{% endif %}

+
+ {% endfor %}
- -