Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,7 +111,7 @@ def catalog():
|
|
| 111 |
background-color: #f5f5f5;
|
| 112 |
color: #333;
|
| 113 |
line-height: 1.6;
|
| 114 |
-
padding:
|
| 115 |
}
|
| 116 |
.container {
|
| 117 |
max-width: 1200px;
|
|
@@ -119,13 +119,13 @@ def catalog():
|
|
| 119 |
}
|
| 120 |
.search-container {
|
| 121 |
text-align: center;
|
| 122 |
-
margin-bottom:
|
| 123 |
}
|
| 124 |
#search-input {
|
| 125 |
-
width:
|
| 126 |
max-width: 500px;
|
| 127 |
-
padding:
|
| 128 |
-
font-size:
|
| 129 |
border: 1px solid #ddd;
|
| 130 |
border-radius: 5px;
|
| 131 |
outline: none;
|
|
@@ -135,33 +135,43 @@ def catalog():
|
|
| 135 |
box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
|
| 136 |
}
|
| 137 |
.products-grid {
|
| 138 |
-
display:
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
.product {
|
|
|
|
| 144 |
background: #ffffff;
|
| 145 |
-
border-radius:
|
| 146 |
-
padding:
|
| 147 |
-
|
| 148 |
display: flex;
|
| 149 |
flex-direction: column;
|
| 150 |
-
|
| 151 |
-
}
|
| 152 |
-
.product:hover {
|
| 153 |
-
transform: translateY(-5px);
|
| 154 |
-
box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
|
| 155 |
}
|
| 156 |
.product-image {
|
| 157 |
width: 100%;
|
| 158 |
-
|
| 159 |
-
height: 200px;
|
| 160 |
background-color: #fff;
|
| 161 |
border-radius: 8px;
|
| 162 |
-
margin: 0 auto 15px;
|
| 163 |
overflow: hidden;
|
| 164 |
-
position: relative;
|
| 165 |
display: flex;
|
| 166 |
justify-content: center;
|
| 167 |
align-items: center;
|
|
@@ -169,8 +179,6 @@ def catalog():
|
|
| 169 |
.product-image img {
|
| 170 |
max-width: 100%;
|
| 171 |
max-height: 100%;
|
| 172 |
-
width: auto;
|
| 173 |
-
height: auto;
|
| 174 |
object-fit: contain;
|
| 175 |
transition: transform 0.3s ease;
|
| 176 |
}
|
|
@@ -178,30 +186,42 @@ def catalog():
|
|
| 178 |
transform: scale(1.05);
|
| 179 |
}
|
| 180 |
.product h2 {
|
| 181 |
-
font-size:
|
| 182 |
-
color: #
|
| 183 |
-
margin
|
| 184 |
font-weight: 600;
|
| 185 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
.product-price {
|
| 188 |
-
font-size: 1.
|
| 189 |
-
color: #
|
| 190 |
font-weight: 700;
|
| 191 |
-
margin:
|
| 192 |
text-align: center;
|
| 193 |
}
|
| 194 |
.product-description {
|
| 195 |
-
color: #
|
| 196 |
-
font-size: 0.
|
| 197 |
flex-grow: 1;
|
| 198 |
-
margin-bottom:
|
| 199 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
.product-button {
|
| 202 |
background-color: #3498db;
|
| 203 |
color: white;
|
| 204 |
-
padding:
|
| 205 |
border: none;
|
| 206 |
border-radius: 5px;
|
| 207 |
cursor: pointer;
|
|
@@ -210,8 +230,7 @@ def catalog():
|
|
| 210 |
text-decoration: none;
|
| 211 |
display: block;
|
| 212 |
margin: 5px auto;
|
| 213 |
-
font-
|
| 214 |
-
font-size: 0.9em;
|
| 215 |
}
|
| 216 |
.product-button:hover {
|
| 217 |
background-color: #2980b9;
|
|
@@ -230,9 +249,9 @@ def catalog():
|
|
| 230 |
color: white;
|
| 231 |
border: none;
|
| 232 |
border-radius: 50%;
|
| 233 |
-
width:
|
| 234 |
-
height:
|
| 235 |
-
font-size:
|
| 236 |
cursor: pointer;
|
| 237 |
display: none;
|
| 238 |
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
|
@@ -312,73 +331,34 @@ def catalog():
|
|
| 312 |
.order-button:hover {
|
| 313 |
background-color: #20B956;
|
| 314 |
}
|
| 315 |
-
@media (
|
| 316 |
-
body {
|
| 317 |
-
padding: 10px;
|
| 318 |
-
}
|
| 319 |
.products-grid {
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
padding: 0 10px;
|
| 323 |
}
|
| 324 |
.product {
|
| 325 |
-
|
| 326 |
}
|
| 327 |
.product-image {
|
| 328 |
-
|
| 329 |
-
height: 150px;
|
| 330 |
}
|
| 331 |
.product h2 {
|
| 332 |
-
font-size:
|
| 333 |
}
|
| 334 |
.product-price {
|
| 335 |
-
font-size: 1.
|
| 336 |
}
|
| 337 |
.product-description {
|
| 338 |
-
font-size: 0.85em;
|
| 339 |
-
}
|
| 340 |
-
.product-button {
|
| 341 |
-
padding: 6px 12px;
|
| 342 |
-
font-size: 0.85em;
|
| 343 |
-
}
|
| 344 |
-
#cart-button {
|
| 345 |
-
width: 40px;
|
| 346 |
-
height: 40px;
|
| 347 |
-
font-size: 16px;
|
| 348 |
-
}
|
| 349 |
-
.modal-content {
|
| 350 |
-
width: 95%;
|
| 351 |
-
padding: 10px;
|
| 352 |
-
}
|
| 353 |
-
.search-container {
|
| 354 |
-
margin-bottom: 20px;
|
| 355 |
-
}
|
| 356 |
-
#search-input {
|
| 357 |
-
width: 90%;
|
| 358 |
font-size: 0.9em;
|
| 359 |
}
|
| 360 |
-
|
| 361 |
-
@media (max-width: 480px) {
|
| 362 |
-
.products-grid {
|
| 363 |
-
gap: 10px;
|
| 364 |
-
padding: 0 5px;
|
| 365 |
-
}
|
| 366 |
-
.product-image {
|
| 367 |
-
max-width: 120px;
|
| 368 |
-
height: 120px;
|
| 369 |
-
}
|
| 370 |
-
.product h2 {
|
| 371 |
font-size: 0.9em;
|
|
|
|
| 372 |
}
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
font-size: 0.8em;
|
| 378 |
-
}
|
| 379 |
-
.product-button {
|
| 380 |
-
padding: 5px 10px;
|
| 381 |
-
font-size: 0.8em;
|
| 382 |
}
|
| 383 |
}
|
| 384 |
</style>
|
|
@@ -400,7 +380,8 @@ def catalog():
|
|
| 400 |
{% endif %}
|
| 401 |
<h2>{{ product['name'] }}</h2>
|
| 402 |
<div class="product-price">{{ product['price'] }}</div>
|
| 403 |
-
<p class="product-description">{{ product['description'][:
|
|
|
|
| 404 |
<button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
|
| 405 |
<button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
|
| 406 |
</div>
|
|
@@ -740,7 +721,8 @@ def admin():
|
|
| 740 |
'name': name,
|
| 741 |
'price': price,
|
| 742 |
'description': description,
|
| 743 |
-
'photos': photos_list
|
|
|
|
| 744 |
}
|
| 745 |
|
| 746 |
products.append(new_product)
|
|
@@ -908,6 +890,8 @@ def admin():
|
|
| 908 |
<input type="number" id="price" name="price" step="0.01" required>
|
| 909 |
<label for="description">Описание:</label>
|
| 910 |
<textarea id="description" name="description" rows="4" required></textarea>
|
|
|
|
|
|
|
| 911 |
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 912 |
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 913 |
<button type="submit">Добавить товар</button>
|
|
@@ -928,6 +912,7 @@ def admin():
|
|
| 928 |
<h3>{{ product['name'] }}</h3>
|
| 929 |
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 930 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
|
|
|
| 931 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 932 |
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|
| 933 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
@@ -946,6 +931,8 @@ def admin():
|
|
| 946 |
<input type="number" id="price" name="price" step="0.01" value="{{ product['price'] }}" required>
|
| 947 |
<label for="description">Описание:</label>
|
| 948 |
<textarea id="description" name="description" rows="4" required>{{ product['description'] }}</textarea>
|
|
|
|
|
|
|
| 949 |
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 950 |
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 951 |
<button type="submit">Сохранить изменения</button>
|
|
@@ -983,4 +970,4 @@ if __name__ == '__main__':
|
|
| 983 |
except Exception as e:
|
| 984 |
logging.error(f"Не удалось загрузить базу данных при запуске: {e}")
|
| 985 |
|
| 986 |
-
app.run(debug=True, host='0.0.0.0', port=7860)
|
|
|
|
| 111 |
background-color: #f5f5f5;
|
| 112 |
color: #333;
|
| 113 |
line-height: 1.6;
|
| 114 |
+
padding: 10px;
|
| 115 |
}
|
| 116 |
.container {
|
| 117 |
max-width: 1200px;
|
|
|
|
| 119 |
}
|
| 120 |
.search-container {
|
| 121 |
text-align: center;
|
| 122 |
+
margin-bottom: 20px;
|
| 123 |
}
|
| 124 |
#search-input {
|
| 125 |
+
width: 90%;
|
| 126 |
max-width: 500px;
|
| 127 |
+
padding: 8px;
|
| 128 |
+
font-size: 0.9em;
|
| 129 |
border: 1px solid #ddd;
|
| 130 |
border-radius: 5px;
|
| 131 |
outline: none;
|
|
|
|
| 135 |
box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
|
| 136 |
}
|
| 137 |
.products-grid {
|
| 138 |
+
display: flex;
|
| 139 |
+
flex-wrap: nowrap;
|
| 140 |
+
overflow-x: auto;
|
| 141 |
+
gap: 10px;
|
| 142 |
+
padding: 10px 0;
|
| 143 |
+
-webkit-overflow-scrolling: touch;
|
| 144 |
+
scrollbar-width: thin;
|
| 145 |
+
scrollbar-color: #888 #f5f5f5;
|
| 146 |
+
}
|
| 147 |
+
.products-grid::-webkit-scrollbar {
|
| 148 |
+
height: 8px;
|
| 149 |
+
}
|
| 150 |
+
.products-grid::-webkit-scrollbar-track {
|
| 151 |
+
background: #f5f5f5;
|
| 152 |
+
border-radius: 10px;
|
| 153 |
+
}
|
| 154 |
+
.products-grid::-webkit-scrollbar-thumb {
|
| 155 |
+
background-color: #888;
|
| 156 |
+
border-radius: 10px;
|
| 157 |
+
border: 2px solid #f5f5f5;
|
| 158 |
}
|
| 159 |
.product {
|
| 160 |
+
flex: 0 0 50%;
|
| 161 |
background: #ffffff;
|
| 162 |
+
border-radius: 10px;
|
| 163 |
+
padding: 10px;
|
| 164 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 165 |
display: flex;
|
| 166 |
flex-direction: column;
|
| 167 |
+
min-width: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
.product-image {
|
| 170 |
width: 100%;
|
| 171 |
+
aspect-ratio: 1;
|
|
|
|
| 172 |
background-color: #fff;
|
| 173 |
border-radius: 8px;
|
|
|
|
| 174 |
overflow: hidden;
|
|
|
|
| 175 |
display: flex;
|
| 176 |
justify-content: center;
|
| 177 |
align-items: center;
|
|
|
|
| 179 |
.product-image img {
|
| 180 |
max-width: 100%;
|
| 181 |
max-height: 100%;
|
|
|
|
|
|
|
| 182 |
object-fit: contain;
|
| 183 |
transition: transform 0.3s ease;
|
| 184 |
}
|
|
|
|
| 186 |
transform: scale(1.05);
|
| 187 |
}
|
| 188 |
.product h2 {
|
| 189 |
+
font-size: 1em;
|
| 190 |
+
color: #333;
|
| 191 |
+
margin: 10px 0 5px;
|
| 192 |
font-weight: 600;
|
| 193 |
text-align: center;
|
| 194 |
+
overflow: hidden;
|
| 195 |
+
text-overflow: ellipsis;
|
| 196 |
+
white-space: nowrap;
|
| 197 |
}
|
| 198 |
.product-price {
|
| 199 |
+
font-size: 1.1em;
|
| 200 |
+
color: #ff0000;
|
| 201 |
font-weight: 700;
|
| 202 |
+
margin: 5px 0;
|
| 203 |
text-align: center;
|
| 204 |
}
|
| 205 |
.product-description {
|
| 206 |
+
color: #666;
|
| 207 |
+
font-size: 0.8em;
|
| 208 |
flex-grow: 1;
|
| 209 |
+
margin-bottom: 10px;
|
| 210 |
text-align: center;
|
| 211 |
+
overflow: hidden;
|
| 212 |
+
text-overflow: ellipsis;
|
| 213 |
+
white-space: nowrap;
|
| 214 |
+
}
|
| 215 |
+
.product-popularity {
|
| 216 |
+
color: #666;
|
| 217 |
+
font-size: 0.7em;
|
| 218 |
+
text-align: center;
|
| 219 |
+
margin-bottom: 5px;
|
| 220 |
}
|
| 221 |
.product-button {
|
| 222 |
background-color: #3498db;
|
| 223 |
color: white;
|
| 224 |
+
padding: 6px 12px;
|
| 225 |
border: none;
|
| 226 |
border-radius: 5px;
|
| 227 |
cursor: pointer;
|
|
|
|
| 230 |
text-decoration: none;
|
| 231 |
display: block;
|
| 232 |
margin: 5px auto;
|
| 233 |
+
font-size: 0.8em;
|
|
|
|
| 234 |
}
|
| 235 |
.product-button:hover {
|
| 236 |
background-color: #2980b9;
|
|
|
|
| 249 |
color: white;
|
| 250 |
border: none;
|
| 251 |
border-radius: 50%;
|
| 252 |
+
width: 40px;
|
| 253 |
+
height: 40px;
|
| 254 |
+
font-size: 16px;
|
| 255 |
cursor: pointer;
|
| 256 |
display: none;
|
| 257 |
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
|
|
|
| 331 |
.order-button:hover {
|
| 332 |
background-color: #20B956;
|
| 333 |
}
|
| 334 |
+
@media (min-width: 768px) {
|
|
|
|
|
|
|
|
|
|
| 335 |
.products-grid {
|
| 336 |
+
flex-wrap: wrap;
|
| 337 |
+
overflow-x: hidden;
|
|
|
|
| 338 |
}
|
| 339 |
.product {
|
| 340 |
+
flex: 0 0 calc(50% - 10px);
|
| 341 |
}
|
| 342 |
.product-image {
|
| 343 |
+
aspect-ratio: 1;
|
|
|
|
| 344 |
}
|
| 345 |
.product h2 {
|
| 346 |
+
font-size: 1.2em;
|
| 347 |
}
|
| 348 |
.product-price {
|
| 349 |
+
font-size: 1.3em;
|
| 350 |
}
|
| 351 |
.product-description {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
font-size: 0.9em;
|
| 353 |
}
|
| 354 |
+
.product-button {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
font-size: 0.9em;
|
| 356 |
+
padding: 8px 15px;
|
| 357 |
}
|
| 358 |
+
#cart-button {
|
| 359 |
+
width: 50px;
|
| 360 |
+
height: 50px;
|
| 361 |
+
font-size: 18px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
}
|
| 363 |
}
|
| 364 |
</style>
|
|
|
|
| 380 |
{% endif %}
|
| 381 |
<h2>{{ product['name'] }}</h2>
|
| 382 |
<div class="product-price">{{ product['price'] }}</div>
|
| 383 |
+
<p class="product-description">{{ product['description'][:50] }}{% if product['description']|length > 50 %}...{% endif %}</p>
|
| 384 |
+
<p class="product-popularity">Продано {{ product.get('sales', '0') }}+ раз</p>
|
| 385 |
<button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
|
| 386 |
<button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
|
| 387 |
</div>
|
|
|
|
| 721 |
'name': name,
|
| 722 |
'price': price,
|
| 723 |
'description': description,
|
| 724 |
+
'photos': photos_list,
|
| 725 |
+
'sales': 0 # Добавляем поле для количества продаж
|
| 726 |
}
|
| 727 |
|
| 728 |
products.append(new_product)
|
|
|
|
| 890 |
<input type="number" id="price" name="price" step="0.01" required>
|
| 891 |
<label for="description">Описание:</label>
|
| 892 |
<textarea id="description" name="description" rows="4" required></textarea>
|
| 893 |
+
<label for="sales">Количество продаж (примерно):</label>
|
| 894 |
+
<input type="number" id="sales" name="sales" value="0" min="0">
|
| 895 |
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 896 |
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 897 |
<button type="submit">Добавить товар</button>
|
|
|
|
| 912 |
<h3>{{ product['name'] }}</h3>
|
| 913 |
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 914 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 915 |
+
<p><strong>Продано:</strong> {{ product['sales'] }}+ раз</p>
|
| 916 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 917 |
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|
| 918 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
|
|
| 931 |
<input type="number" id="price" name="price" step="0.01" value="{{ product['price'] }}" required>
|
| 932 |
<label for="description">Описание:</label>
|
| 933 |
<textarea id="description" name="description" rows="4" required>{{ product['description'] }}</textarea>
|
| 934 |
+
<label for="sales">Количество продаж:</label>
|
| 935 |
+
<input type="number" id="sales" name="sales" value="{{ product['sales'] }}" min="0">
|
| 936 |
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 937 |
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 938 |
<button type="submit">Сохранить изменения</button>
|
|
|
|
| 970 |
except Exception as e:
|
| 971 |
logging.error(f"Не удалось загрузить базу данных при запуске: {e}")
|
| 972 |
|
| 973 |
+
app.run(debug=True, host='0.0.0.0', port=7860)
|