Spaces:
Runtime error
Runtime error
Update app.py
Browse files97 unmodified lines98991001011021031041051061071081091101111121131141155 unmodified lines1211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621637 unmodified lines17117217317417517617717817918018118218318418518618718818919019197 unmodified lines# Pagination setuppage = request.args.get('page', 1, type=int)per_page = 6 # Adjusted for mobile view# Calculate start and end indices for the current pagestart = (page - 1) * per_page * 3 # 3 columns for bigger screensend = start + per_page * 3# Slice the products list for the current pagepaginated_products = products[start:end]# Calculate total number of pagestotal_products = len(products)total_pages = (total_products + (per_page * 3) - 1) // (per_page * 3)catalog_html = '''<!DOCTYPE html>5 unmodified lines<style>body {font-family: Arial, sans-serif;margin: 0; /* Reset default margin */background-color: #f9f9f9;padding: 20px;}h1 {color: #333;text-align: center;}.container {display: flex;flex-wrap: wrap;justify-content: space-around;gap: 20px;}.product {flex: 1 1 calc(100% - 20px); /* Full width on mobile */background-color: #fff;border: 1px solid #ddd;padding: 15px;border-radius: 5px;text-align: center;box-shadow: 0px 2px 5px rgba(0,0,0,0.1);}.product img {max-width: 100%;height: auto;border-radius: 5px;margin-bottom: 10px;}.pagination {text-align: center;margin-top: 20px;}.pagination a {display: inline-block;padding: 8px 16px;text-decoration: none;border: 1px solid #ddd;color: #333;background-color: white;7 unmodified lines.pagination a:hover:not(.active) {background-color: #ddd;}/* Media query for larger screens */@media (min-width: 768px) {.product {flex: 1 1 calc(30% - 20px); /* Three columns on larger screens */}}</style></head><body><h1>Каталог товаров</h1><div class="container">{% for product in paginated_products %}<div class="product"><h2>{{ product['name'] }}</h2>{% if product.get('photo') %}<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photo'] }}" alt="{{ product['name'] }}">97 unmodified lines98991001011021031041051061071081091101111121131141155 unmodified lines1211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761777 unmodified lines18518618718818919019119219319419519619719897 unmodified lines# Pagination setuppage = request.args.get('page', 1, type=int)per_page = 12 # Количество товаров на странице# Calculate start and end indices for the current pagestart = (page - 1) * per_pageend = start + per_page# Slice the products list for the current pagepaginated_products = products[start:end]# Calculate total number of pagestotal_products = len(products)total_pages = (total_products + per_page - 1) // per_pagecatalog_html = '''<!DOCTYPE html>5 unmodified lines<style>body {font-family: Arial, sans-serif;margin: 0;padding: 20px;background-color: #f9f9f9;}h1 {text-align: center;color: #333;margin-bottom: 20px;}.grid-container {display: grid;grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));gap: 20px;margin-bottom: 20px;}.product-card {background-color: white;border-radius: 8px;box-shadow: 0 2px 5px rgba(0,0,0,0.1);padding: 15px;text-align: center;transition: transform 0.2s ease-in-out;}.product-card:hover {transform: scale(1.05);}.product-card img {max-width: 100%;height: auto;border-radius: 5px;margin-bottom: 10px;}.product-card h2 {font-size: 18px;color: #555;margin-bottom: 10px;}.product-card p {font-size: 14px;color: #777;margin-bottom: 5px;}.pagination {text-align: center;margin-top: 20px;}.pagination a {display: inline-block;padding: 10px 15px;text-decoration: none;border-radius: 5px;border: 1px solid #ddd;color: #333;background-color: white;7 unmodified lines.pagination a:hover:not(.active) {background-color: #ddd;}</style></head><body><h1>Каталог товаров</h1><div class="grid-container">{% for product in paginated_products %}<div class="product-card"><h2>{{ product['name'] }}</h2>{% if product.get('photo') %}<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photo'] }}" alt="{{ product['name'] }}">
app.py+35-28