Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,18 +98,18 @@ def catalog():
|
|
| 98 |
|
| 99 |
# Pagination setup
|
| 100 |
page = request.args.get('page', 1, type=int)
|
| 101 |
-
per_page =
|
| 102 |
|
| 103 |
# Calculate start and end indices for the current page
|
| 104 |
-
start = (page - 1) * per_page
|
| 105 |
-
end = start + per_page
|
| 106 |
|
| 107 |
# Slice the products list for the current page
|
| 108 |
paginated_products = products[start:end]
|
| 109 |
|
| 110 |
# Calculate total number of pages
|
| 111 |
total_products = len(products)
|
| 112 |
-
total_pages = (total_products +
|
| 113 |
|
| 114 |
catalog_html = '''
|
| 115 |
<!DOCTYPE html>
|
|
@@ -121,43 +121,57 @@ def catalog():
|
|
| 121 |
<style>
|
| 122 |
body {
|
| 123 |
font-family: Arial, sans-serif;
|
| 124 |
-
margin: 0;
|
| 125 |
-
background-color: #f9f9f9;
|
| 126 |
padding: 20px;
|
|
|
|
| 127 |
}
|
| 128 |
h1 {
|
| 129 |
-
color: #333;
|
| 130 |
text-align: center;
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
-
.container {
|
| 133 |
-
display:
|
| 134 |
-
|
| 135 |
-
justify-content: space-around;
|
| 136 |
gap: 20px;
|
|
|
|
| 137 |
}
|
| 138 |
-
.product {
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
padding: 15px;
|
| 143 |
-
border-radius: 5px;
|
| 144 |
text-align: center;
|
| 145 |
-
|
| 146 |
}
|
| 147 |
-
.product
|
|
|
|
|
|
|
|
|
|
| 148 |
max-width: 100%;
|
| 149 |
height: auto;
|
| 150 |
border-radius: 5px;
|
| 151 |
margin-bottom: 10px;
|
| 152 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
.pagination {
|
| 154 |
text-align: center;
|
| 155 |
margin-top: 20px;
|
| 156 |
}
|
| 157 |
.pagination a {
|
| 158 |
display: inline-block;
|
| 159 |
-
padding:
|
| 160 |
text-decoration: none;
|
|
|
|
| 161 |
border: 1px solid #ddd;
|
| 162 |
color: #333;
|
| 163 |
background-color: white;
|
|
@@ -171,21 +185,14 @@ def catalog():
|
|
| 171 |
.pagination a:hover:not(.active) {
|
| 172 |
background-color: #ddd;
|
| 173 |
}
|
| 174 |
-
|
| 175 |
-
/* Media query for larger screens */
|
| 176 |
-
@media (min-width: 768px) {
|
| 177 |
-
.product {
|
| 178 |
-
flex: 1 1 calc(30% - 20px); /* Three columns on larger screens */
|
| 179 |
-
}
|
| 180 |
-
}
|
| 181 |
</style>
|
| 182 |
</head>
|
| 183 |
<body>
|
| 184 |
<h1>Каталог товаров</h1>
|
| 185 |
|
| 186 |
-
<div class="container">
|
| 187 |
{% for product in paginated_products %}
|
| 188 |
-
<div class="product">
|
| 189 |
<h2>{{ product['name'] }}</h2>
|
| 190 |
{% if product.get('photo') %}
|
| 191 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photo'] }}" alt="{{ product['name'] }}">
|
|
|
|
| 98 |
|
| 99 |
# Pagination setup
|
| 100 |
page = request.args.get('page', 1, type=int)
|
| 101 |
+
per_page = 12 # Количество товаров на странице
|
| 102 |
|
| 103 |
# Calculate start and end indices for the current page
|
| 104 |
+
start = (page - 1) * per_page
|
| 105 |
+
end = start + per_page
|
| 106 |
|
| 107 |
# Slice the products list for the current page
|
| 108 |
paginated_products = products[start:end]
|
| 109 |
|
| 110 |
# Calculate total number of pages
|
| 111 |
total_products = len(products)
|
| 112 |
+
total_pages = (total_products + per_page - 1) // per_page
|
| 113 |
|
| 114 |
catalog_html = '''
|
| 115 |
<!DOCTYPE html>
|
|
|
|
| 121 |
<style>
|
| 122 |
body {
|
| 123 |
font-family: Arial, sans-serif;
|
| 124 |
+
margin: 0;
|
|
|
|
| 125 |
padding: 20px;
|
| 126 |
+
background-color: #f9f9f9;
|
| 127 |
}
|
| 128 |
h1 {
|
|
|
|
| 129 |
text-align: center;
|
| 130 |
+
color: #333;
|
| 131 |
+
margin-bottom: 20px;
|
| 132 |
}
|
| 133 |
+
.grid-container {
|
| 134 |
+
display: grid;
|
| 135 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
|
|
| 136 |
gap: 20px;
|
| 137 |
+
margin-bottom: 20px;
|
| 138 |
}
|
| 139 |
+
.product-card {
|
| 140 |
+
background-color: white;
|
| 141 |
+
border-radius: 8px;
|
| 142 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 143 |
padding: 15px;
|
|
|
|
| 144 |
text-align: center;
|
| 145 |
+
transition: transform 0.2s ease-in-out;
|
| 146 |
}
|
| 147 |
+
.product-card:hover {
|
| 148 |
+
transform: scale(1.05);
|
| 149 |
+
}
|
| 150 |
+
.product-card img {
|
| 151 |
max-width: 100%;
|
| 152 |
height: auto;
|
| 153 |
border-radius: 5px;
|
| 154 |
margin-bottom: 10px;
|
| 155 |
}
|
| 156 |
+
.product-card h2 {
|
| 157 |
+
font-size: 18px;
|
| 158 |
+
color: #555;
|
| 159 |
+
margin-bottom: 10px;
|
| 160 |
+
}
|
| 161 |
+
.product-card p {
|
| 162 |
+
font-size: 14px;
|
| 163 |
+
color: #777;
|
| 164 |
+
margin-bottom: 5px;
|
| 165 |
+
}
|
| 166 |
.pagination {
|
| 167 |
text-align: center;
|
| 168 |
margin-top: 20px;
|
| 169 |
}
|
| 170 |
.pagination a {
|
| 171 |
display: inline-block;
|
| 172 |
+
padding: 10px 15px;
|
| 173 |
text-decoration: none;
|
| 174 |
+
border-radius: 5px;
|
| 175 |
border: 1px solid #ddd;
|
| 176 |
color: #333;
|
| 177 |
background-color: white;
|
|
|
|
| 185 |
.pagination a:hover:not(.active) {
|
| 186 |
background-color: #ddd;
|
| 187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
</style>
|
| 189 |
</head>
|
| 190 |
<body>
|
| 191 |
<h1>Каталог товаров</h1>
|
| 192 |
|
| 193 |
+
<div class="grid-container">
|
| 194 |
{% for product in paginated_products %}
|
| 195 |
+
<div class="product-card">
|
| 196 |
<h2>{{ product['name'] }}</h2>
|
| 197 |
{% if product.get('photo') %}
|
| 198 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photo'] }}" alt="{{ product['name'] }}">
|