Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,27 +108,14 @@ def catalog():
|
|
| 108 |
}
|
| 109 |
body {
|
| 110 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 111 |
-
background:
|
| 112 |
-
color: #
|
| 113 |
line-height: 1.6;
|
| 114 |
padding: 20px;
|
| 115 |
}
|
| 116 |
.container {
|
| 117 |
max-width: 1200px;
|
| 118 |
margin: 0 auto;
|
| 119 |
-
background: rgba(0, 0, 0, 0.1);
|
| 120 |
-
border-radius: 5px;
|
| 121 |
-
padding: 20px;
|
| 122 |
-
}
|
| 123 |
-
.logo {
|
| 124 |
-
display: flex;
|
| 125 |
-
align-items: center;
|
| 126 |
-
justify-content: center;
|
| 127 |
-
margin-bottom: 20px;
|
| 128 |
-
}
|
| 129 |
-
.logo img {
|
| 130 |
-
width: 50px;
|
| 131 |
-
height: 50px;
|
| 132 |
}
|
| 133 |
.search-container {
|
| 134 |
text-align: center;
|
|
@@ -137,47 +124,40 @@ def catalog():
|
|
| 137 |
#search-input {
|
| 138 |
width: 80%;
|
| 139 |
max-width: 500px;
|
| 140 |
-
padding:
|
| 141 |
font-size: 1em;
|
| 142 |
-
border:
|
| 143 |
border-radius: 5px;
|
| 144 |
outline: none;
|
| 145 |
-
background-color: #ffffff;
|
| 146 |
-
color: #2e6a6a;
|
| 147 |
-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
| 148 |
-
}
|
| 149 |
-
#search-input::placeholder {
|
| 150 |
-
color: #2e6a6a;
|
| 151 |
-
opacity: 0.7;
|
| 152 |
}
|
| 153 |
#search-input:focus {
|
| 154 |
-
border-color: #
|
| 155 |
-
box-shadow: 0 0
|
| 156 |
}
|
| 157 |
.products-grid {
|
| 158 |
display: grid;
|
| 159 |
-
grid-template-columns: repeat(
|
| 160 |
gap: 20px;
|
| 161 |
padding: 0 15px;
|
| 162 |
}
|
| 163 |
.product {
|
| 164 |
-
background:
|
| 165 |
-
border-radius:
|
| 166 |
padding: 20px;
|
| 167 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 168 |
display: flex;
|
| 169 |
flex-direction: column;
|
| 170 |
-
box-shadow: 0 2px
|
| 171 |
}
|
| 172 |
.product:hover {
|
| 173 |
transform: translateY(-5px);
|
| 174 |
-
box-shadow: 0 5px
|
| 175 |
}
|
| 176 |
.product-image {
|
| 177 |
width: 200px;
|
| 178 |
height: 200px;
|
| 179 |
-
background-color: #
|
| 180 |
-
border-radius:
|
| 181 |
margin: 0 auto 15px;
|
| 182 |
overflow: hidden;
|
| 183 |
position: relative;
|
|
@@ -198,33 +178,33 @@ def catalog():
|
|
| 198 |
}
|
| 199 |
.product h2 {
|
| 200 |
font-size: 1.2em;
|
| 201 |
-
color: #
|
| 202 |
margin-bottom: 10px;
|
| 203 |
font-weight: 600;
|
| 204 |
text-align: center;
|
| 205 |
}
|
| 206 |
.product-price {
|
| 207 |
font-size: 1.3em;
|
| 208 |
-
color: #
|
| 209 |
font-weight: 700;
|
| 210 |
margin: 10px 0;
|
| 211 |
text-align: center;
|
| 212 |
}
|
| 213 |
.product-description {
|
| 214 |
-
color: #
|
| 215 |
font-size: 0.9em;
|
| 216 |
flex-grow: 1;
|
| 217 |
margin-bottom: 15px;
|
| 218 |
text-align: center;
|
| 219 |
}
|
| 220 |
.product-button {
|
| 221 |
-
background:
|
| 222 |
-
color:
|
| 223 |
padding: 10px 20px;
|
| 224 |
border: none;
|
| 225 |
border-radius: 5px;
|
| 226 |
cursor: pointer;
|
| 227 |
-
transition: background 0.3s ease;
|
| 228 |
text-align: center;
|
| 229 |
text-decoration: none;
|
| 230 |
display: block;
|
|
@@ -232,20 +212,20 @@ def catalog():
|
|
| 232 |
font-weight: 500;
|
| 233 |
}
|
| 234 |
.product-button:hover {
|
| 235 |
-
background:
|
| 236 |
}
|
| 237 |
.add-to-cart {
|
| 238 |
-
background:
|
| 239 |
}
|
| 240 |
.add-to-cart:hover {
|
| 241 |
-
background:
|
| 242 |
}
|
| 243 |
#cart-button {
|
| 244 |
position: fixed;
|
| 245 |
bottom: 20px;
|
| 246 |
right: 20px;
|
| 247 |
-
background:
|
| 248 |
-
color:
|
| 249 |
border: none;
|
| 250 |
border-radius: 50%;
|
| 251 |
width: 60px;
|
|
@@ -253,11 +233,11 @@ def catalog():
|
|
| 253 |
font-size: 20px;
|
| 254 |
cursor: pointer;
|
| 255 |
display: none;
|
| 256 |
-
box-shadow: 0 2px 10px rgba(0,
|
| 257 |
z-index: 1000;
|
| 258 |
}
|
| 259 |
#cart-button:hover {
|
| 260 |
-
background:
|
| 261 |
}
|
| 262 |
.modal {
|
| 263 |
display: none;
|
|
@@ -268,166 +248,71 @@ def catalog():
|
|
| 268 |
width: 100%;
|
| 269 |
height: 100%;
|
| 270 |
overflow: auto;
|
| 271 |
-
background-color: rgba(0,
|
| 272 |
}
|
| 273 |
.modal-content {
|
| 274 |
position: relative;
|
| 275 |
-
background:
|
| 276 |
margin: 10% auto;
|
| 277 |
padding: 20px;
|
| 278 |
-
border: 1px solid
|
| 279 |
width: 80%;
|
| 280 |
max-width: 600px;
|
| 281 |
-
box-shadow: 0 4px 8px rgba(0,
|
| 282 |
-
|
| 283 |
-
color: #ffffff;
|
| 284 |
}
|
| 285 |
@keyframes animatetop {
|
| 286 |
from {top: -300px; opacity: 0}
|
| 287 |
to {top: 10%; opacity: 1}
|
| 288 |
}
|
| 289 |
.close {
|
| 290 |
-
color: #
|
| 291 |
float: right;
|
| 292 |
font-size: 28px;
|
| 293 |
font-weight: bold;
|
| 294 |
cursor: pointer;
|
| 295 |
}
|
| 296 |
.close:hover {
|
| 297 |
-
color:
|
| 298 |
}
|
| 299 |
.cart-item {
|
| 300 |
display: flex;
|
| 301 |
justify-content: space-between;
|
| 302 |
align-items: center;
|
| 303 |
padding: 10px 0;
|
| 304 |
-
border-bottom: 1px solid
|
| 305 |
}
|
| 306 |
.cart-item img {
|
| 307 |
width: 50px;
|
| 308 |
height: 50px;
|
| 309 |
object-fit: contain;
|
| 310 |
-
background-color: #
|
| 311 |
margin-right: 10px;
|
| 312 |
}
|
| 313 |
.quantity-input {
|
| 314 |
width: 60px;
|
| 315 |
padding: 5px;
|
| 316 |
margin: 10px 0;
|
| 317 |
-
border: 1px solid #ffffff;
|
| 318 |
-
border-radius: 5px;
|
| 319 |
-
background-color: rgba(255, 255, 255, 0.1);
|
| 320 |
-
color: #ffffff;
|
| 321 |
}
|
| 322 |
.clear-cart {
|
| 323 |
-
background:
|
| 324 |
margin-top: 10px;
|
| 325 |
margin-right: 10px;
|
| 326 |
-
border-radius: 5px;
|
| 327 |
-
border: none;
|
| 328 |
}
|
| 329 |
.clear-cart:hover {
|
| 330 |
-
background:
|
| 331 |
}
|
| 332 |
.order-button {
|
| 333 |
-
background:
|
| 334 |
margin-top: 10px;
|
| 335 |
-
border-radius: 5px;
|
| 336 |
-
border: none;
|
| 337 |
}
|
| 338 |
.order-button:hover {
|
| 339 |
-
background:
|
| 340 |
-
}
|
| 341 |
-
@media (max-width: 768px) {
|
| 342 |
-
body {
|
| 343 |
-
padding: 10px;
|
| 344 |
-
}
|
| 345 |
-
.products-grid {
|
| 346 |
-
gap: 15px;
|
| 347 |
-
padding: 0 10px;
|
| 348 |
-
}
|
| 349 |
-
.product {
|
| 350 |
-
padding: 15px;
|
| 351 |
-
}
|
| 352 |
-
.product-image {
|
| 353 |
-
width: 150px;
|
| 354 |
-
height: 150px;
|
| 355 |
-
}
|
| 356 |
-
.product-image img {
|
| 357 |
-
max-width: 150px;
|
| 358 |
-
max-height: 150px;
|
| 359 |
-
}
|
| 360 |
-
.product h2 {
|
| 361 |
-
font-size: 1em;
|
| 362 |
-
}
|
| 363 |
-
.product-price {
|
| 364 |
-
font-size: 1.1em;
|
| 365 |
-
}
|
| 366 |
-
.product-description {
|
| 367 |
-
font-size: 0.85em;
|
| 368 |
-
}
|
| 369 |
-
.product-button {
|
| 370 |
-
padding: 8px 15px;
|
| 371 |
-
font-size: 0.9em;
|
| 372 |
-
}
|
| 373 |
-
#cart-button {
|
| 374 |
-
width: 50px;
|
| 375 |
-
height: 50px;
|
| 376 |
-
font-size: 18px;
|
| 377 |
-
bottom: 15px;
|
| 378 |
-
right: 15px;
|
| 379 |
-
}
|
| 380 |
-
.search-container {
|
| 381 |
-
margin-bottom: 20px;
|
| 382 |
-
}
|
| 383 |
-
#search-input {
|
| 384 |
-
width: 90%;
|
| 385 |
-
}
|
| 386 |
-
}
|
| 387 |
-
@media (max-width: 480px) {
|
| 388 |
-
.products-grid {
|
| 389 |
-
gap: 10px;
|
| 390 |
-
padding: 0 5px;
|
| 391 |
-
}
|
| 392 |
-
.product {
|
| 393 |
-
padding: 10px;
|
| 394 |
-
}
|
| 395 |
-
.product-image {
|
| 396 |
-
width: 120px;
|
| 397 |
-
height: 120px;
|
| 398 |
-
}
|
| 399 |
-
.product-image img {
|
| 400 |
-
max-width: 120px;
|
| 401 |
-
max-height: 120px;
|
| 402 |
-
}
|
| 403 |
-
.search-container {
|
| 404 |
-
margin-bottom: 15px;
|
| 405 |
-
}
|
| 406 |
-
#search-input {
|
| 407 |
-
width: 90%;
|
| 408 |
-
padding: 10px;
|
| 409 |
-
}
|
| 410 |
-
.product h2 {
|
| 411 |
-
font-size: 0.9em;
|
| 412 |
-
}
|
| 413 |
-
.product-price {
|
| 414 |
-
font-size: 1em;
|
| 415 |
-
}
|
| 416 |
-
.product-description {
|
| 417 |
-
font-size: 0.8em;
|
| 418 |
-
}
|
| 419 |
-
.product-button {
|
| 420 |
-
padding: 6px 12px;
|
| 421 |
-
font-size: 0.85em;
|
| 422 |
-
}
|
| 423 |
}
|
| 424 |
</style>
|
| 425 |
</head>
|
| 426 |
<body>
|
| 427 |
<div class="container">
|
| 428 |
-
<div class="logo">
|
| 429 |
-
<img src="https://morshen-alpha-static.hf.space/file=morshen-alpha-static/logo.png" alt="Logo">
|
| 430 |
-
</div>
|
| 431 |
<div class="search-container">
|
| 432 |
<input type="text" id="search-input" placeholder="Поиск по названию или описанию...">
|
| 433 |
</div>
|
|
@@ -528,6 +413,9 @@ def catalog():
|
|
| 528 |
nextEl: '.swiper-button-next',
|
| 529 |
prevEl: '.swiper-button-prev',
|
| 530 |
},
|
|
|
|
|
|
|
|
|
|
| 531 |
});
|
| 532 |
}
|
| 533 |
|
|
@@ -600,7 +488,7 @@ def catalog():
|
|
| 600 |
let total = 0;
|
| 601 |
|
| 602 |
if (cart.length === 0) {
|
| 603 |
-
cartContent.innerHTML = '<p
|
| 604 |
} else {
|
| 605 |
cartContent.innerHTML = cart.map(item => {
|
| 606 |
const itemTotal = item.price * item.quantity;
|
|
@@ -613,11 +501,11 @@ def catalog():
|
|
| 613 |
alt="${item.name}">
|
| 614 |
` : ''}
|
| 615 |
<div>
|
| 616 |
-
<strong
|
| 617 |
-
<p
|
| 618 |
</div>
|
| 619 |
</div>
|
| 620 |
-
<span
|
| 621 |
</div>
|
| 622 |
`;
|
| 623 |
}).join('');
|
|
@@ -696,15 +584,17 @@ def product_detail(index):
|
|
| 696 |
return "Продукт не найден", 404
|
| 697 |
detail_html = '''
|
| 698 |
<div class="container">
|
| 699 |
-
<h2
|
| 700 |
<div class="swiper-container">
|
| 701 |
<div class="swiper-wrapper">
|
| 702 |
{% if product.get('photos') %}
|
| 703 |
{% for photo in product['photos'] %}
|
| 704 |
<div class="swiper-slide" style="background-color: #fff; display: flex; justify-content: center; align-items: center;">
|
| 705 |
-
<
|
| 706 |
-
|
| 707 |
-
|
|
|
|
|
|
|
| 708 |
</div>
|
| 709 |
{% endfor %}
|
| 710 |
{% else %}
|
|
@@ -717,8 +607,8 @@ def product_detail(index):
|
|
| 717 |
<div class="swiper-button-next"></div>
|
| 718 |
<div class="swiper-button-prev"></div>
|
| 719 |
</div>
|
| 720 |
-
<p
|
| 721 |
-
<p
|
| 722 |
</div>
|
| 723 |
'''
|
| 724 |
return render_template_string(detail_html, product=product, repo_id=REPO_ID)
|
|
@@ -859,156 +749,125 @@ def admin():
|
|
| 859 |
<title>Админ-панель</title>
|
| 860 |
<style>
|
| 861 |
body {
|
| 862 |
-
font-family:
|
| 863 |
-
background: linear-gradient(135deg, #1e4a4a, #2e6a6a);
|
| 864 |
-
color: #ffffff;
|
| 865 |
margin: 20px;
|
| 866 |
-
|
| 867 |
-
}
|
| 868 |
-
.container {
|
| 869 |
-
max-width: 1200px;
|
| 870 |
-
margin: 0 auto;
|
| 871 |
-
background: rgba(255, 255, 255, 0.1);
|
| 872 |
-
border-radius: 5px;
|
| 873 |
-
padding: 20px;
|
| 874 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 875 |
}
|
| 876 |
h1 {
|
| 877 |
-
color: #
|
| 878 |
-
text-align: center;
|
| 879 |
-
margin-bottom: 20px;
|
| 880 |
-
font-size: 2em;
|
| 881 |
-
font-weight: 700;
|
| 882 |
-
}
|
| 883 |
-
h2 {
|
| 884 |
-
color: #ffffff;
|
| 885 |
-
text-align: center;
|
| 886 |
-
margin-bottom: 20px;
|
| 887 |
}
|
| 888 |
form {
|
| 889 |
-
background:
|
| 890 |
padding: 20px;
|
| 891 |
-
border: 1px solid
|
| 892 |
border-radius: 5px;
|
|
|
|
| 893 |
margin-bottom: 20px;
|
| 894 |
}
|
| 895 |
label {
|
| 896 |
display: block;
|
| 897 |
margin-top: 10px;
|
| 898 |
-
color: #
|
| 899 |
}
|
| 900 |
input, textarea {
|
| 901 |
width: 100%;
|
| 902 |
padding: 8px;
|
| 903 |
margin-top: 5px;
|
| 904 |
-
border: 1px solid
|
| 905 |
-
border-radius:
|
| 906 |
box-sizing: border-box;
|
| 907 |
-
background: rgba(255, 255, 255, 0.1);
|
| 908 |
-
color: #ffffff;
|
| 909 |
-
}
|
| 910 |
-
input::placeholder, textarea::placeholder {
|
| 911 |
-
color: #e0e0e0;
|
| 912 |
-
opacity: 0.7;
|
| 913 |
}
|
| 914 |
button {
|
| 915 |
margin-top: 15px;
|
| 916 |
-
padding: 10px
|
| 917 |
-
background:
|
| 918 |
-
color:
|
| 919 |
border: none;
|
| 920 |
-
border-radius:
|
| 921 |
cursor: pointer;
|
| 922 |
-
transition: background 0.3s ease;
|
| 923 |
}
|
| 924 |
button:hover {
|
| 925 |
-
background:
|
| 926 |
}
|
| 927 |
.product-list {
|
| 928 |
margin-top: 20px;
|
| 929 |
}
|
| 930 |
.product-item {
|
| 931 |
-
background:
|
| 932 |
-
border: 1px solid
|
| 933 |
padding: 15px;
|
| 934 |
margin-bottom: 10px;
|
| 935 |
border-radius: 5px;
|
| 936 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 937 |
}
|
| 938 |
.edit-form {
|
| 939 |
margin-top: 10px;
|
| 940 |
padding: 10px;
|
| 941 |
-
border: 1px solid
|
| 942 |
border-radius: 5px;
|
| 943 |
-
background:
|
| 944 |
-
}
|
| 945 |
-
p, strong {
|
| 946 |
-
color: #ffffff;
|
| 947 |
}
|
| 948 |
</style>
|
| 949 |
</head>
|
| 950 |
<body>
|
| 951 |
-
<
|
| 952 |
-
|
| 953 |
-
<
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
<
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
<
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
<
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
<
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
<
|
| 989 |
-
|
| 990 |
-
<
|
| 991 |
-
<input type="hidden" name="action" value="edit">
|
| 992 |
-
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 993 |
-
<label for="name">Название товара:</label>
|
| 994 |
-
<input type="text" id="name" name="name" value="{{ product['name'] }}" required>
|
| 995 |
-
<label for="price">Цена:</label>
|
| 996 |
-
<input type="number" id="price" name="price" step="0.01" value="{{ product['price'] }}" required>
|
| 997 |
-
<label for="description">Описание:</label>
|
| 998 |
-
<textarea id="description" name="description" rows="4" required>{{ product['description'] }}</textarea>
|
| 999 |
-
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 1000 |
-
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 1001 |
-
<button type="submit">Сохранить изменения</button>
|
| 1002 |
-
</form>
|
| 1003 |
-
</details>
|
| 1004 |
-
<form method="POST">
|
| 1005 |
-
<input type="hidden" name="action" value="delete">
|
| 1006 |
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 1007 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1008 |
</form>
|
| 1009 |
-
</
|
| 1010 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1011 |
</div>
|
|
|
|
| 1012 |
</div>
|
| 1013 |
</body>
|
| 1014 |
</html>
|
|
|
|
| 108 |
}
|
| 109 |
body {
|
| 110 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 111 |
+
background-color: #f5f5f5;
|
| 112 |
+
color: #333;
|
| 113 |
line-height: 1.6;
|
| 114 |
padding: 20px;
|
| 115 |
}
|
| 116 |
.container {
|
| 117 |
max-width: 1200px;
|
| 118 |
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
.search-container {
|
| 121 |
text-align: center;
|
|
|
|
| 124 |
#search-input {
|
| 125 |
width: 80%;
|
| 126 |
max-width: 500px;
|
| 127 |
+
padding: 10px;
|
| 128 |
font-size: 1em;
|
| 129 |
+
border: 1px solid #ddd;
|
| 130 |
border-radius: 5px;
|
| 131 |
outline: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
#search-input:focus {
|
| 134 |
+
border-color: #3498db;
|
| 135 |
+
box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
|
| 136 |
}
|
| 137 |
.products-grid {
|
| 138 |
display: grid;
|
| 139 |
+
grid-template-columns: repeat(2, 1fr);
|
| 140 |
gap: 20px;
|
| 141 |
padding: 0 15px;
|
| 142 |
}
|
| 143 |
.product {
|
| 144 |
+
background: #ffffff;
|
| 145 |
+
border-radius: 12px;
|
| 146 |
padding: 20px;
|
| 147 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 148 |
display: flex;
|
| 149 |
flex-direction: column;
|
| 150 |
+
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
|
| 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: 200px;
|
| 158 |
height: 200px;
|
| 159 |
+
background-color: #fff;
|
| 160 |
+
border-radius: 8px;
|
| 161 |
margin: 0 auto 15px;
|
| 162 |
overflow: hidden;
|
| 163 |
position: relative;
|
|
|
|
| 178 |
}
|
| 179 |
.product h2 {
|
| 180 |
font-size: 1.2em;
|
| 181 |
+
color: #2c3e50;
|
| 182 |
margin-bottom: 10px;
|
| 183 |
font-weight: 600;
|
| 184 |
text-align: center;
|
| 185 |
}
|
| 186 |
.product-price {
|
| 187 |
font-size: 1.3em;
|
| 188 |
+
color: #e74c3c;
|
| 189 |
font-weight: 700;
|
| 190 |
margin: 10px 0;
|
| 191 |
text-align: center;
|
| 192 |
}
|
| 193 |
.product-description {
|
| 194 |
+
color: #7f8c8d;
|
| 195 |
font-size: 0.9em;
|
| 196 |
flex-grow: 1;
|
| 197 |
margin-bottom: 15px;
|
| 198 |
text-align: center;
|
| 199 |
}
|
| 200 |
.product-button {
|
| 201 |
+
background-color: #3498db;
|
| 202 |
+
color: white;
|
| 203 |
padding: 10px 20px;
|
| 204 |
border: none;
|
| 205 |
border-radius: 5px;
|
| 206 |
cursor: pointer;
|
| 207 |
+
transition: background-color 0.3s ease;
|
| 208 |
text-align: center;
|
| 209 |
text-decoration: none;
|
| 210 |
display: block;
|
|
|
|
| 212 |
font-weight: 500;
|
| 213 |
}
|
| 214 |
.product-button:hover {
|
| 215 |
+
background-color: #2980b9;
|
| 216 |
}
|
| 217 |
.add-to-cart {
|
| 218 |
+
background-color: #27ae60;
|
| 219 |
}
|
| 220 |
.add-to-cart:hover {
|
| 221 |
+
background-color: #219653;
|
| 222 |
}
|
| 223 |
#cart-button {
|
| 224 |
position: fixed;
|
| 225 |
bottom: 20px;
|
| 226 |
right: 20px;
|
| 227 |
+
background-color: #e74c3c;
|
| 228 |
+
color: white;
|
| 229 |
border: none;
|
| 230 |
border-radius: 50%;
|
| 231 |
width: 60px;
|
|
|
|
| 233 |
font-size: 20px;
|
| 234 |
cursor: pointer;
|
| 235 |
display: none;
|
| 236 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
| 237 |
z-index: 1000;
|
| 238 |
}
|
| 239 |
#cart-button:hover {
|
| 240 |
+
background-color: #c0392b;
|
| 241 |
}
|
| 242 |
.modal {
|
| 243 |
display: none;
|
|
|
|
| 248 |
width: 100%;
|
| 249 |
height: 100%;
|
| 250 |
overflow: auto;
|
| 251 |
+
background-color: rgba(0,0,0,0.4);
|
| 252 |
}
|
| 253 |
.modal-content {
|
| 254 |
position: relative;
|
| 255 |
+
background-color: #fefefe;
|
| 256 |
margin: 10% auto;
|
| 257 |
padding: 20px;
|
| 258 |
+
border: 1px solid #888;
|
| 259 |
width: 80%;
|
| 260 |
max-width: 600px;
|
| 261 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
| 262 |
+
animation: animatetop 0.4s;
|
|
|
|
| 263 |
}
|
| 264 |
@keyframes animatetop {
|
| 265 |
from {top: -300px; opacity: 0}
|
| 266 |
to {top: 10%; opacity: 1}
|
| 267 |
}
|
| 268 |
.close {
|
| 269 |
+
color: #aaa;
|
| 270 |
float: right;
|
| 271 |
font-size: 28px;
|
| 272 |
font-weight: bold;
|
| 273 |
cursor: pointer;
|
| 274 |
}
|
| 275 |
.close:hover {
|
| 276 |
+
color: black;
|
| 277 |
}
|
| 278 |
.cart-item {
|
| 279 |
display: flex;
|
| 280 |
justify-content: space-between;
|
| 281 |
align-items: center;
|
| 282 |
padding: 10px 0;
|
| 283 |
+
border-bottom: 1px solid #eee;
|
| 284 |
}
|
| 285 |
.cart-item img {
|
| 286 |
width: 50px;
|
| 287 |
height: 50px;
|
| 288 |
object-fit: contain;
|
| 289 |
+
background-color: #fff;
|
| 290 |
margin-right: 10px;
|
| 291 |
}
|
| 292 |
.quantity-input {
|
| 293 |
width: 60px;
|
| 294 |
padding: 5px;
|
| 295 |
margin: 10px 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
}
|
| 297 |
.clear-cart {
|
| 298 |
+
background-color: #e74c3c;
|
| 299 |
margin-top: 10px;
|
| 300 |
margin-right: 10px;
|
|
|
|
|
|
|
| 301 |
}
|
| 302 |
.clear-cart:hover {
|
| 303 |
+
background-color: #c0392b;
|
| 304 |
}
|
| 305 |
.order-button {
|
| 306 |
+
background-color: #25D366;
|
| 307 |
margin-top: 10px;
|
|
|
|
|
|
|
| 308 |
}
|
| 309 |
.order-button:hover {
|
| 310 |
+
background-color: #20B956;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
}
|
| 312 |
</style>
|
| 313 |
</head>
|
| 314 |
<body>
|
| 315 |
<div class="container">
|
|
|
|
|
|
|
|
|
|
| 316 |
<div class="search-container">
|
| 317 |
<input type="text" id="search-input" placeholder="Поиск по названию или описанию...">
|
| 318 |
</div>
|
|
|
|
| 413 |
nextEl: '.swiper-button-next',
|
| 414 |
prevEl: '.swiper-button-prev',
|
| 415 |
},
|
| 416 |
+
zoom: {
|
| 417 |
+
maxRatio: 3,
|
| 418 |
+
},
|
| 419 |
});
|
| 420 |
}
|
| 421 |
|
|
|
|
| 488 |
let total = 0;
|
| 489 |
|
| 490 |
if (cart.length === 0) {
|
| 491 |
+
cartContent.innerHTML = '<p>Корзина пуста</p>';
|
| 492 |
} else {
|
| 493 |
cartContent.innerHTML = cart.map(item => {
|
| 494 |
const itemTotal = item.price * item.quantity;
|
|
|
|
| 501 |
alt="${item.name}">
|
| 502 |
` : ''}
|
| 503 |
<div>
|
| 504 |
+
<strong>${item.name}</strong>
|
| 505 |
+
<p>${item.price} × ${item.quantity}</p>
|
| 506 |
</div>
|
| 507 |
</div>
|
| 508 |
+
<span>${itemTotal}</span>
|
| 509 |
</div>
|
| 510 |
`;
|
| 511 |
}).join('');
|
|
|
|
| 584 |
return "Продукт не найден", 404
|
| 585 |
detail_html = '''
|
| 586 |
<div class="container">
|
| 587 |
+
<h2>{{ product['name'] }}</h2>
|
| 588 |
<div class="swiper-container">
|
| 589 |
<div class="swiper-wrapper">
|
| 590 |
{% if product.get('photos') %}
|
| 591 |
{% for photo in product['photos'] %}
|
| 592 |
<div class="swiper-slide" style="background-color: #fff; display: flex; justify-content: center; align-items: center;">
|
| 593 |
+
<div class="swiper-zoom-container">
|
| 594 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
|
| 595 |
+
alt="{{ product['name'] }}"
|
| 596 |
+
style="max-width: 200px; max-height: 200px; width: auto; height: auto; object-fit: contain;">
|
| 597 |
+
</div>
|
| 598 |
</div>
|
| 599 |
{% endfor %}
|
| 600 |
{% else %}
|
|
|
|
| 607 |
<div class="swiper-button-next"></div>
|
| 608 |
<div class="swiper-button-prev"></div>
|
| 609 |
</div>
|
| 610 |
+
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 611 |
+
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 612 |
</div>
|
| 613 |
'''
|
| 614 |
return render_template_string(detail_html, product=product, repo_id=REPO_ID)
|
|
|
|
| 749 |
<title>Админ-панель</title>
|
| 750 |
<style>
|
| 751 |
body {
|
| 752 |
+
font-family: Arial, sans-serif;
|
|
|
|
|
|
|
| 753 |
margin: 20px;
|
| 754 |
+
background-color: #f9f9f9;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
}
|
| 756 |
h1 {
|
| 757 |
+
color: #333;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 758 |
}
|
| 759 |
form {
|
| 760 |
+
background-color: #fff;
|
| 761 |
padding: 20px;
|
| 762 |
+
border: 1px solid #ddd;
|
| 763 |
border-radius: 5px;
|
| 764 |
+
max-width: 100%;
|
| 765 |
margin-bottom: 20px;
|
| 766 |
}
|
| 767 |
label {
|
| 768 |
display: block;
|
| 769 |
margin-top: 10px;
|
| 770 |
+
color: #555;
|
| 771 |
}
|
| 772 |
input, textarea {
|
| 773 |
width: 100%;
|
| 774 |
padding: 8px;
|
| 775 |
margin-top: 5px;
|
| 776 |
+
border: 1px solid #ddd;
|
| 777 |
+
border-radius: 4px;
|
| 778 |
box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 779 |
}
|
| 780 |
button {
|
| 781 |
margin-top: 15px;
|
| 782 |
+
padding: 10px 15px;
|
| 783 |
+
background-color: #28a745;
|
| 784 |
+
color: white;
|
| 785 |
border: none;
|
| 786 |
+
border-radius: 4px;
|
| 787 |
cursor: pointer;
|
|
|
|
| 788 |
}
|
| 789 |
button:hover {
|
| 790 |
+
background-color: #218838;
|
| 791 |
}
|
| 792 |
.product-list {
|
| 793 |
margin-top: 20px;
|
| 794 |
}
|
| 795 |
.product-item {
|
| 796 |
+
background-color: #fff;
|
| 797 |
+
border: 1px solid #ddd;
|
| 798 |
padding: 15px;
|
| 799 |
margin-bottom: 10px;
|
| 800 |
border-radius: 5px;
|
|
|
|
| 801 |
}
|
| 802 |
.edit-form {
|
| 803 |
margin-top: 10px;
|
| 804 |
padding: 10px;
|
| 805 |
+
border: 1px solid #ddd;
|
| 806 |
border-radius: 5px;
|
| 807 |
+
background-color: #f9f9f9;
|
|
|
|
|
|
|
|
|
|
| 808 |
}
|
| 809 |
</style>
|
| 810 |
</head>
|
| 811 |
<body>
|
| 812 |
+
<h1>Добавление товара</h1>
|
| 813 |
+
<form method="POST" enctype="multipart/form-data">
|
| 814 |
+
<input type="hidden" name="action" value="add">
|
| 815 |
+
<label for="name">Название товара:</label>
|
| 816 |
+
<input type="text" id="name" name="name" required>
|
| 817 |
+
<label for="price">Цена:</label>
|
| 818 |
+
<input type="number" id="price" name="price" step="0.01" required>
|
| 819 |
+
<label for="description">Описание:</label>
|
| 820 |
+
<textarea id="description" name="description" rows="4" required></textarea>
|
| 821 |
+
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 822 |
+
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 823 |
+
<button type="submit">Добавить товар</button>
|
| 824 |
+
</form>
|
| 825 |
+
|
| 826 |
+
<h2>Управление базой данных</h2>
|
| 827 |
+
<form method="POST" action="{{ url_for('backup') }}">
|
| 828 |
+
<button type="submit">Создать резервную копию</button>
|
| 829 |
+
</form>
|
| 830 |
+
<form method="GET" action="{{ url_for('download') }}">
|
| 831 |
+
<button type="submit">Скачать базу данных</button>
|
| 832 |
+
</form>
|
| 833 |
+
|
| 834 |
+
<h2>Список товаров</h2>
|
| 835 |
+
<div class="product-list">
|
| 836 |
+
{% for product in products %}
|
| 837 |
+
<div class="product-item">
|
| 838 |
+
<h3>{{ product['name'] }}</h3>
|
| 839 |
+
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 840 |
+
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 841 |
+
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 842 |
+
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|
| 843 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
| 844 |
+
alt="{{ product['name'] }}"
|
| 845 |
+
style="max-width: 100px; max-height: 100px; width: auto; height: auto; object-fit: contain;">
|
| 846 |
+
</div>
|
| 847 |
+
{% endif %}
|
| 848 |
+
<details>
|
| 849 |
+
<summary>Редактировать</summary>
|
| 850 |
+
<form method="POST" enctype="multipart/form-data" class="edit-form">
|
| 851 |
+
<input type="hidden" name="action" value="edit">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 853 |
+
<label for="name">Название товара:</label>
|
| 854 |
+
<input type="text" id="name" name="name" value="{{ product['name'] }}" required>
|
| 855 |
+
<label for="price">Цена:</label>
|
| 856 |
+
<input type="number" id="price" name="price" step="0.01" value="{{ product['price'] }}" required>
|
| 857 |
+
<label for="description">Описание:</label>
|
| 858 |
+
<textarea id="description" name="description" rows="4" required>{{ product['description'] }}</textarea>
|
| 859 |
+
<label for="photos">Фотографии товара (максимум 2):</label>
|
| 860 |
+
<input type="file" id="photos" name="photos" accept="image/*" multiple>
|
| 861 |
+
<button type="submit">Сохранить изменения</button>
|
| 862 |
</form>
|
| 863 |
+
</details>
|
| 864 |
+
<form method="POST">
|
| 865 |
+
<input type="hidden" name="action" value="delete">
|
| 866 |
+
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 867 |
+
<button type="submit">Удалить</button>
|
| 868 |
+
</form>
|
| 869 |
</div>
|
| 870 |
+
{% endfor %}
|
| 871 |
</div>
|
| 872 |
</body>
|
| 873 |
</html>
|