flpolprojects commited on
Commit
24d83f7
·
verified ·
1 Parent(s): d1010e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -105,12 +105,11 @@ def catalog():
105
  <head>
106
  <meta charset="UTF-8">
107
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
108
- <title>Asdem пижамы и нижнее белье оптом </title>
109
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
110
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
111
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
112
  <style>
113
- /* Существующие стили остаются без изменений */
114
  * {
115
  margin: 0;
116
  padding: 0;
@@ -750,11 +749,11 @@ def admin():
750
  description = request.form.get('description')
751
  category = request.form.get('category')
752
  photos_files = request.files.getlist('photos')
753
- colors = request.form.getlist('colors') # Получаем список цветов
754
  photos_list = []
755
 
756
  if photos_files:
757
- for photo in photos_files[:2]:
758
  if photo and photo.filename:
759
  photo_filename = secure_filename(photo.filename)
760
  uploads_dir = 'uploads'
@@ -784,7 +783,7 @@ def admin():
784
  'description': description,
785
  'category': category if category in categories else 'Без категории',
786
  'photos': photos_list,
787
- 'colors': colors if colors else [] # Добавляем цвета
788
  }
789
  products.append(new_product)
790
  save_data(data)
@@ -797,11 +796,11 @@ def admin():
797
  description = request.form.get('description')
798
  category = request.form.get('category')
799
  photos_files = request.files.getlist('photos')
800
- colors = request.form.getlist('colors') # Обновляем цвета
801
 
802
  if photos_files and any(photo.filename for photo in photos_files):
803
  new_photos_list = []
804
- for photo in photos_files[:2]:
805
  if photo and photo.filename:
806
  photo_filename = secure_filename(photo.filename)
807
  uploads_dir = 'uploads'
@@ -826,7 +825,7 @@ def admin():
826
  products[index]['price'] = float(price.replace(',', '.'))
827
  products[index]['description'] = description
828
  products[index]['category'] = category if category in categories else 'Без категории'
829
- products[index]['colors'] = colors if colors else [] # Обновляем цвета
830
  save_data(data)
831
  return redirect(url_for('admin'))
832
 
@@ -978,7 +977,7 @@ def admin():
978
  <option value="{{ category }}">{{ category }}</option>
979
  {% endfor %}
980
  </select>
981
- <label>Фотографии (до 2):</label>
982
  <input type="file" name="photos" accept="image/*" multiple>
983
  <label>Цвета:</label>
984
  <div id="color-inputs">
@@ -1030,9 +1029,13 @@ def admin():
1030
  <p><strong>Описание:</strong> {{ product['description'] }}</p>
1031
  <p><strong>Цвета:</strong> {{ product.get('colors', ['Нет цветов'])|join(', ') }}</p>
1032
  {% if product.get('photos') and product['photos']|length > 0 %}
1033
- <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
1034
- alt="{{ product['name'] }}"
1035
- style="max-width: 100px; border-radius: 10px;">
 
 
 
 
1036
  {% endif %}
1037
  <details>
1038
  <summary>Редактировать</summary>
@@ -1052,7 +1055,7 @@ def admin():
1052
  <option value="{{ category }}" {% if product.get('category') == category %}selected{% endif %}>{{ category }}</option>
1053
  {% endfor %}
1054
  </select>
1055
- <label>Фотографии:</label>
1056
  <input type="file" name="photos" accept="image/*" multiple>
1057
  <label>Цвета:</label>
1058
  <div id="edit-color-inputs-{{ loop.index0 }}">
 
105
  <head>
106
  <meta charset="UTF-8">
107
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
108
+ <title>Routine wholesale - Женская одежда</title>
109
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
110
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
111
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
112
  <style>
 
113
  * {
114
  margin: 0;
115
  padding: 0;
 
749
  description = request.form.get('description')
750
  category = request.form.get('category')
751
  photos_files = request.files.getlist('photos')
752
+ colors = request.form.getlist('colors')
753
  photos_list = []
754
 
755
  if photos_files:
756
+ for photo in photos_files[:10]: # Ограничение до 10 фото
757
  if photo and photo.filename:
758
  photo_filename = secure_filename(photo.filename)
759
  uploads_dir = 'uploads'
 
783
  'description': description,
784
  'category': category if category in categories else 'Без категории',
785
  'photos': photos_list,
786
+ 'colors': colors if colors else []
787
  }
788
  products.append(new_product)
789
  save_data(data)
 
796
  description = request.form.get('description')
797
  category = request.form.get('category')
798
  photos_files = request.files.getlist('photos')
799
+ colors = request.form.getlist('colors')
800
 
801
  if photos_files and any(photo.filename for photo in photos_files):
802
  new_photos_list = []
803
+ for photo in photos_files[:10]: # Ограничение до 10 фото
804
  if photo and photo.filename:
805
  photo_filename = secure_filename(photo.filename)
806
  uploads_dir = 'uploads'
 
825
  products[index]['price'] = float(price.replace(',', '.'))
826
  products[index]['description'] = description
827
  products[index]['category'] = category if category in categories else 'Без категории'
828
+ products[index]['colors'] = colors if colors else []
829
  save_data(data)
830
  return redirect(url_for('admin'))
831
 
 
977
  <option value="{{ category }}">{{ category }}</option>
978
  {% endfor %}
979
  </select>
980
+ <label>Фотографии (до 10):</label>
981
  <input type="file" name="photos" accept="image/*" multiple>
982
  <label>Цвета:</label>
983
  <div id="color-inputs">
 
1029
  <p><strong>Описание:</strong> {{ product['description'] }}</p>
1030
  <p><strong>Цвета:</strong> {{ product.get('colors', ['Нет цветов'])|join(', ') }}</p>
1031
  {% if product.get('photos') and product['photos']|length > 0 %}
1032
+ <div style="display: flex; flex-wrap: wrap; gap: 10px;">
1033
+ {% for photo in product['photos'] %}
1034
+ <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
1035
+ alt="{{ product['name'] }}"
1036
+ style="max-width: 100px; border-radius: 10px;">
1037
+ {% endfor %}
1038
+ </div>
1039
  {% endif %}
1040
  <details>
1041
  <summary>Редактировать</summary>
 
1055
  <option value="{{ category }}" {% if product.get('category') == category %}selected{% endif %}>{{ category }}</option>
1056
  {% endfor %}
1057
  </select>
1058
+ <label>Фотографии (до 10):</label>
1059
  <input type="file" name="photos" accept="image/*" multiple>
1060
  <label>Цвета:</label>
1061
  <div id="edit-color-inputs-{{ loop.index0 }}">