Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ import uuid
|
|
| 16 |
load_dotenv()
|
| 17 |
|
| 18 |
app = Flask(__name__)
|
| 19 |
-
app.secret_key = '
|
| 20 |
DATA_FILE = 'data.json'
|
| 21 |
|
| 22 |
SYNC_FILES = [DATA_FILE]
|
|
@@ -25,7 +25,7 @@ REPO_ID = "Kgshop/abamstyle"
|
|
| 25 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 26 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
|
| 27 |
|
| 28 |
-
STORE_ADDRESS = "Точка продаж
|
| 29 |
|
| 30 |
CURRENCY_CODE = 'KGS'
|
| 31 |
CURRENCY_NAME = 'Кыргызский сом'
|
|
@@ -206,7 +206,7 @@ CATALOG_TEMPLATE = '''
|
|
| 206 |
<head>
|
| 207 |
<meta charset="UTF-8">
|
| 208 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 209 |
-
<title>
|
| 210 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 211 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 212 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
|
|
@@ -280,7 +280,7 @@ CATALOG_TEMPLATE = '''
|
|
| 280 |
<body>
|
| 281 |
<div class="container">
|
| 282 |
<div class="header">
|
| 283 |
-
<h1><img src="https://
|
| 284 |
</div>
|
| 285 |
|
| 286 |
<div class="store-address">Наш адрес: {{ store_address }}</div>
|
|
@@ -690,7 +690,7 @@ CATALOG_TEMPLATE = '''
|
|
| 690 |
});
|
| 691 |
});
|
| 692 |
filterProducts();
|
| 693 |
-
|
| 694 |
|
| 695 |
function showNotification(message, duration = 3000) {
|
| 696 |
const placeholder = document.getElementById('notification-placeholder');
|
|
@@ -776,7 +776,7 @@ PRODUCT_DETAIL_TEMPLATE = '''
|
|
| 776 |
<div style="margin-top: 20px; font-size: 1rem; line-height: 1.7; color: #ccc;">
|
| 777 |
<p><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
|
| 778 |
<p style="font-size: 1.2rem; font-weight: bold; color: #ffd700;"><strong>Цена:</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}</p>
|
| 779 |
-
<p><strong>Описание:</strong><br> {{ product.get('description', 'Описание отсутствует.')
|
| 780 |
{% set colors = product.get('colors', []) %}
|
| 781 |
{% if colors and colors|select('ne', '')|list|length > 0 %}
|
| 782 |
<p><strong>Доступные цвета/варианты:</strong> {{ colors|select('ne', '')|join(', ') }}</p>
|
|
@@ -791,7 +791,7 @@ ORDER_TEMPLATE = '''
|
|
| 791 |
<head>
|
| 792 |
<meta charset="UTF-8">
|
| 793 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 794 |
-
<title>Заказ №{{ order.id }} -
|
| 795 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 796 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 797 |
<style>
|
|
@@ -865,9 +865,9 @@ ORDER_TEMPLATE = '''
|
|
| 865 |
function sendOrderViaWhatsApp() {
|
| 866 |
const orderId = '{{ order.id }}';
|
| 867 |
const orderUrl = `{{ request.url }}`;
|
| 868 |
-
const whatsappNumber = "
|
| 869 |
|
| 870 |
-
let message = `Здравствуйте! Хочу подтвердить свой заказ на
|
| 871 |
message += `*Номер заказа:* ${orderId}%0A`;
|
| 872 |
message += `*Ссылка на заказ:* ${encodeURIComponent(orderUrl)}%0A%0A`;
|
| 873 |
message += `Пожалуйста, свяжитесь со мной для уточнения деталей оплаты и доставки.`;
|
|
@@ -893,7 +893,7 @@ ADMIN_TEMPLATE = '''
|
|
| 893 |
<head>
|
| 894 |
<meta charset="UTF-8">
|
| 895 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 896 |
-
<title>Админ-панель -
|
| 897 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 898 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 899 |
<style>
|
|
@@ -966,7 +966,7 @@ ADMIN_TEMPLATE = '''
|
|
| 966 |
<body>
|
| 967 |
<div class="container">
|
| 968 |
<div class="header">
|
| 969 |
-
<h1><img src="https://
|
| 970 |
<a href="{{ url_for('catalog') }}" class="button catalog-link-button"><i class="fas fa-store"></i> Перейти в каталог</a>
|
| 971 |
</div>
|
| 972 |
|
|
@@ -1472,11 +1472,6 @@ def admin():
|
|
| 1472 |
except OSError: pass
|
| 1473 |
elif photo and not photo.filename:
|
| 1474 |
logging.warning("Received an empty photo file object when adding product.")
|
| 1475 |
-
try:
|
| 1476 |
-
if os.path.exists(uploads_dir) and not os.listdir(uploads_dir):
|
| 1477 |
-
os.rmdir(uploads_dir)
|
| 1478 |
-
except OSError as e:
|
| 1479 |
-
logging.warning(f"Could not remove temporary upload directory {uploads_dir}: {e}")
|
| 1480 |
elif not HF_TOKEN_WRITE and photos_files and any(f.filename for f in photos_files):
|
| 1481 |
flash("HF_TOKEN (write) не настроен. Фотографии не были загружены.", "warning")
|
| 1482 |
|
|
|
|
| 16 |
load_dotenv()
|
| 17 |
|
| 18 |
app = Flask(__name__)
|
| 19 |
+
app.secret_key = 'your_unique_secret_key_abam_style_12345_no_login'
|
| 20 |
DATA_FILE = 'data.json'
|
| 21 |
|
| 22 |
SYNC_FILES = [DATA_FILE]
|
|
|
|
| 25 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 26 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
|
| 27 |
|
| 28 |
+
STORE_ADDRESS = "Точка продаж : Рынок Дордой , Брючный проход , 137 контейнер . Производство : Асаналиева 119А "
|
| 29 |
|
| 30 |
CURRENCY_CODE = 'KGS'
|
| 31 |
CURRENCY_NAME = 'Кыргызский сом'
|
|
|
|
| 206 |
<head>
|
| 207 |
<meta charset="UTF-8">
|
| 208 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 209 |
+
<title>Abam Style - Каталог</title>
|
| 210 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 211 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 212 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
|
|
|
|
| 280 |
<body>
|
| 281 |
<div class="container">
|
| 282 |
<div class="header">
|
| 283 |
+
<h1><img src="https://huggingface.co/spaces/Abam-style/Optom/resolve/main/484269034_1278319193255433_5382124474251993844_n.jpg" alt="Abam Style Logo">Abam Style</h1>
|
| 284 |
</div>
|
| 285 |
|
| 286 |
<div class="store-address">Наш адрес: {{ store_address }}</div>
|
|
|
|
| 690 |
});
|
| 691 |
});
|
| 692 |
filterProducts();
|
| 693 |
+
}
|
| 694 |
|
| 695 |
function showNotification(message, duration = 3000) {
|
| 696 |
const placeholder = document.getElementById('notification-placeholder');
|
|
|
|
| 776 |
<div style="margin-top: 20px; font-size: 1rem; line-height: 1.7; color: #ccc;">
|
| 777 |
<p><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
|
| 778 |
<p style="font-size: 1.2rem; font-weight: bold; color: #ffd700;"><strong>Цена:</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}</p>
|
| 779 |
+
<p><strong>Описание:</strong><br> {{ product.get('description', 'Описание отсутствует.').replace('\\n', '<br>')|safe }}</p>
|
| 780 |
{% set colors = product.get('colors', []) %}
|
| 781 |
{% if colors and colors|select('ne', '')|list|length > 0 %}
|
| 782 |
<p><strong>Доступные цвета/варианты:</strong> {{ colors|select('ne', '')|join(', ') }}</p>
|
|
|
|
| 791 |
<head>
|
| 792 |
<meta charset="UTF-8">
|
| 793 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 794 |
+
<title>Заказ №{{ order.id }} - Abam Style</title>
|
| 795 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 796 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 797 |
<style>
|
|
|
|
| 865 |
function sendOrderViaWhatsApp() {
|
| 866 |
const orderId = '{{ order.id }}';
|
| 867 |
const orderUrl = `{{ request.url }}`;
|
| 868 |
+
const whatsappNumber = "996559493939";
|
| 869 |
|
| 870 |
+
let message = `Здравствуйте! Хочу подтвердить свой заказ на Abam Style:%0A%0A`;
|
| 871 |
message += `*Номер заказа:* ${orderId}%0A`;
|
| 872 |
message += `*Ссылка на заказ:* ${encodeURIComponent(orderUrl)}%0A%0A`;
|
| 873 |
message += `Пожалуйста, свяжитесь со мной для уточнения деталей оплаты и доставки.`;
|
|
|
|
| 893 |
<head>
|
| 894 |
<meta charset="UTF-8">
|
| 895 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 896 |
+
<title>Админ-панель - Abam Style</title>
|
| 897 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 898 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 899 |
<style>
|
|
|
|
| 966 |
<body>
|
| 967 |
<div class="container">
|
| 968 |
<div class="header">
|
| 969 |
+
<h1><img src="https://huggingface.co/spaces/Abam-style/Optom/resolve/main/484269034_1278319193255433_5382124474251993844_n.jpg" alt="Abam Style Logo"> Админ-панель Abam Style</h1>
|
| 970 |
<a href="{{ url_for('catalog') }}" class="button catalog-link-button"><i class="fas fa-store"></i> Перейти в каталог</a>
|
| 971 |
</div>
|
| 972 |
|
|
|
|
| 1472 |
except OSError: pass
|
| 1473 |
elif photo and not photo.filename:
|
| 1474 |
logging.warning("Received an empty photo file object when adding product.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1475 |
elif not HF_TOKEN_WRITE and photos_files and any(f.filename for f in photos_files):
|
| 1476 |
flash("HF_TOKEN (write) не настроен. Фотографии не были загружены.", "warning")
|
| 1477 |
|