Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,964 +0,0 @@
|
|
| 1 |
-
from flask import Flask, render_template_string, request, redirect, url_for, send_file, flash, jsonify
|
| 2 |
-
import json
|
| 3 |
-
import os
|
| 4 |
-
import logging
|
| 5 |
-
import threading
|
| 6 |
-
import time
|
| 7 |
-
from datetime import datetime
|
| 8 |
-
from huggingface_hub import HfApi, hf_hub_download
|
| 9 |
-
from huggingface_hub.utils import RepositoryNotFoundError, HfHubHTTPError
|
| 10 |
-
from werkzeug.utils import secure_filename
|
| 11 |
-
from dotenv import load_dotenv
|
| 12 |
-
import requests
|
| 13 |
-
import uuid
|
| 14 |
-
|
| 15 |
-
load_dotenv()
|
| 16 |
-
|
| 17 |
-
app = Flask(__name__)
|
| 18 |
-
app.secret_key = 'osoo_raina_secret_key_12345_no_login'
|
| 19 |
-
DATA_FILE = 'data.json'
|
| 20 |
-
|
| 21 |
-
SYNC_FILES = [DATA_FILE]
|
| 22 |
-
|
| 23 |
-
REPO_ID = "Kgshop/raina"
|
| 24 |
-
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 25 |
-
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
|
| 26 |
-
|
| 27 |
-
COMPANY_NAME = "ОсОО «Раина»"
|
| 28 |
-
|
| 29 |
-
DOWNLOAD_RETRIES = 3
|
| 30 |
-
DOWNLOAD_DELAY = 5
|
| 31 |
-
|
| 32 |
-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 33 |
-
|
| 34 |
-
def download_db_from_hf(specific_file=None, retries=DOWNLOAD_RETRIES, delay=DOWNLOAD_DELAY):
|
| 35 |
-
if not HF_TOKEN_READ and not HF_TOKEN_WRITE:
|
| 36 |
-
logging.warning("HF_TOKEN_READ/HF_TOKEN_WRITE not set. Download might fail for private repos.")
|
| 37 |
-
|
| 38 |
-
token_to_use = HF_TOKEN_READ if HF_TOKEN_READ else HF_TOKEN_WRITE
|
| 39 |
-
|
| 40 |
-
files_to_download = [specific_file] if specific_file else SYNC_FILES
|
| 41 |
-
logging.info(f"Attempting download for {files_to_download} from {REPO_ID}...")
|
| 42 |
-
all_successful = True
|
| 43 |
-
|
| 44 |
-
for file_name in files_to_download:
|
| 45 |
-
success = False
|
| 46 |
-
for attempt in range(retries + 1):
|
| 47 |
-
try:
|
| 48 |
-
logging.info(f"Downloading {file_name} (Attempt {attempt + 1}/{retries + 1})...")
|
| 49 |
-
local_path = hf_hub_download(
|
| 50 |
-
repo_id=REPO_ID,
|
| 51 |
-
filename=file_name,
|
| 52 |
-
repo_type="dataset",
|
| 53 |
-
token=token_to_use,
|
| 54 |
-
local_dir=".",
|
| 55 |
-
local_dir_use_symlinks=False,
|
| 56 |
-
force_download=True,
|
| 57 |
-
resume_download=False
|
| 58 |
-
)
|
| 59 |
-
logging.info(f"Successfully downloaded {file_name} to {local_path}.")
|
| 60 |
-
success = True
|
| 61 |
-
break
|
| 62 |
-
except RepositoryNotFoundError:
|
| 63 |
-
logging.error(f"Repository {REPO_ID} not found. Download cancelled for all files.")
|
| 64 |
-
return False
|
| 65 |
-
except HfHubHTTPError as e:
|
| 66 |
-
if e.response.status_code == 404:
|
| 67 |
-
logging.warning(f"File {file_name} not found in repo {REPO_ID} (404). Skipping this file.")
|
| 68 |
-
if attempt == 0 and not os.path.exists(file_name):
|
| 69 |
-
try:
|
| 70 |
-
if file_name == DATA_FILE:
|
| 71 |
-
with open(file_name, 'w', encoding='utf-8') as f:
|
| 72 |
-
json.dump({'equipment': [], 'categories': [], 'turnkey_services': []}, f)
|
| 73 |
-
logging.info(f"Created empty local file {file_name} because it was not found on HF.")
|
| 74 |
-
except Exception as create_e:
|
| 75 |
-
logging.error(f"Failed to create empty local file {file_name}: {create_e}")
|
| 76 |
-
success = False
|
| 77 |
-
break
|
| 78 |
-
else:
|
| 79 |
-
logging.error(f"HTTP error downloading {file_name} (Attempt {attempt + 1}): {e}. Retrying in {delay}s...")
|
| 80 |
-
except requests.exceptions.RequestException as e:
|
| 81 |
-
logging.error(f"Network error downloading {file_name} (Attempt {attempt + 1}): {e}. Retrying in {delay}s...")
|
| 82 |
-
except Exception as e:
|
| 83 |
-
logging.error(f"Unexpected error downloading {file_name} (Attempt {attempt + 1}): {e}. Retrying in {delay}s...", exc_info=True)
|
| 84 |
-
|
| 85 |
-
if attempt < retries:
|
| 86 |
-
time.sleep(delay)
|
| 87 |
-
|
| 88 |
-
if not success:
|
| 89 |
-
logging.error(f"Failed to download {file_name} after {retries + 1} attempts.")
|
| 90 |
-
all_successful = False
|
| 91 |
-
|
| 92 |
-
logging.info(f"Download process finished. Overall success: {all_successful}")
|
| 93 |
-
return all_successful
|
| 94 |
-
|
| 95 |
-
def upload_db_to_hf(specific_file=None):
|
| 96 |
-
if not HF_TOKEN_WRITE:
|
| 97 |
-
logging.warning("HF_TOKEN (for writing) not set. Skipping upload to Hugging Face.")
|
| 98 |
-
return
|
| 99 |
-
try:
|
| 100 |
-
api = HfApi()
|
| 101 |
-
files_to_upload = [specific_file] if specific_file else SYNC_FILES
|
| 102 |
-
logging.info(f"Starting upload of {files_to_upload} to HF repo {REPO_ID}...")
|
| 103 |
-
|
| 104 |
-
for file_name in files_to_upload:
|
| 105 |
-
if os.path.exists(file_name):
|
| 106 |
-
try:
|
| 107 |
-
api.upload_file(
|
| 108 |
-
path_or_fileobj=file_name,
|
| 109 |
-
path_in_repo=file_name,
|
| 110 |
-
repo_id=REPO_ID,
|
| 111 |
-
repo_type="dataset",
|
| 112 |
-
token=HF_TOKEN_WRITE,
|
| 113 |
-
commit_message=f"Sync {file_name} {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
| 114 |
-
)
|
| 115 |
-
logging.info(f"File {file_name} successfully uploaded to Hugging Face.")
|
| 116 |
-
except Exception as e:
|
| 117 |
-
logging.error(f"Error uploading file {file_name} to Hugging Face: {e}")
|
| 118 |
-
else:
|
| 119 |
-
logging.warning(f"File {file_name} not found locally, skipping upload.")
|
| 120 |
-
logging.info("Finished uploading files to HF.")
|
| 121 |
-
except Exception as e:
|
| 122 |
-
logging.error(f"General error during Hugging Face upload initialization or process: {e}", exc_info=True)
|
| 123 |
-
|
| 124 |
-
def periodic_backup():
|
| 125 |
-
backup_interval = 1800
|
| 126 |
-
logging.info(f"Setting up periodic backup every {backup_interval} seconds.")
|
| 127 |
-
while True:
|
| 128 |
-
time.sleep(backup_interval)
|
| 129 |
-
logging.info("Starting periodic backup...")
|
| 130 |
-
upload_db_to_hf()
|
| 131 |
-
logging.info("Periodic backup finished.")
|
| 132 |
-
|
| 133 |
-
def load_data():
|
| 134 |
-
default_data = {'equipment': [], 'categories': [], 'turnkey_services': []}
|
| 135 |
-
try:
|
| 136 |
-
with open(DATA_FILE, 'r', encoding='utf-8') as file:
|
| 137 |
-
data = json.load(file)
|
| 138 |
-
logging.info(f"Local data loaded successfully from {DATA_FILE}")
|
| 139 |
-
if not isinstance(data, dict):
|
| 140 |
-
logging.warning(f"Local {DATA_FILE} is not a dictionary. Attempting download.")
|
| 141 |
-
raise FileNotFoundError
|
| 142 |
-
if 'equipment' not in data: data['equipment'] = []
|
| 143 |
-
if 'categories' not in data: data['categories'] = []
|
| 144 |
-
if 'turnkey_services' not in data: data['turnkey_services'] = []
|
| 145 |
-
return data
|
| 146 |
-
except (FileNotFoundError, json.JSONDecodeError):
|
| 147 |
-
logging.warning(f"Local file {DATA_FILE} not found or corrupt. Attempting download from HF.")
|
| 148 |
-
|
| 149 |
-
if download_db_from_hf(specific_file=DATA_FILE):
|
| 150 |
-
try:
|
| 151 |
-
with open(DATA_FILE, 'r', encoding='utf-8') as file:
|
| 152 |
-
data = json.load(file)
|
| 153 |
-
logging.info(f"Data loaded successfully from {DATA_FILE} after download.")
|
| 154 |
-
if not isinstance(data, dict):
|
| 155 |
-
logging.error(f"Downloaded {DATA_FILE} is not a dictionary. Using default.")
|
| 156 |
-
return default_data
|
| 157 |
-
if 'equipment' not in data: data['equipment'] = []
|
| 158 |
-
if 'categories' not in data: data['categories'] = []
|
| 159 |
-
if 'turnkey_services' not in data: data['turnkey_services'] = []
|
| 160 |
-
return data
|
| 161 |
-
except (FileNotFoundError, json.JSONDecodeError, Exception) as e:
|
| 162 |
-
logging.error(f"Error loading downloaded {DATA_FILE}: {e}. Using default.", exc_info=True)
|
| 163 |
-
return default_data
|
| 164 |
-
else:
|
| 165 |
-
logging.error(f"Failed to download {DATA_FILE} from HF. Using empty default data structure.")
|
| 166 |
-
if not os.path.exists(DATA_FILE):
|
| 167 |
-
try:
|
| 168 |
-
with open(DATA_FILE, 'w', encoding='utf-8') as f:
|
| 169 |
-
json.dump(default_data, f)
|
| 170 |
-
logging.info(f"Created empty local file {DATA_FILE} after failed download.")
|
| 171 |
-
except Exception as create_e:
|
| 172 |
-
logging.error(f"Failed to create empty local file {DATA_FILE}: {create_e}")
|
| 173 |
-
return default_data
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
def save_data(data):
|
| 177 |
-
try:
|
| 178 |
-
if not isinstance(data, dict):
|
| 179 |
-
logging.error("Attempted to save invalid data structure (not a dict). Aborting save.")
|
| 180 |
-
return
|
| 181 |
-
if 'equipment' not in data: data['equipment'] = []
|
| 182 |
-
if 'categories' not in data: data['categories'] = []
|
| 183 |
-
if 'turnkey_services' not in data: data['turnkey_services'] = []
|
| 184 |
-
|
| 185 |
-
with open(DATA_FILE, 'w', encoding='utf-8') as file:
|
| 186 |
-
json.dump(data, file, ensure_ascii=False, indent=4)
|
| 187 |
-
logging.info(f"Data successfully saved to {DATA_FILE}")
|
| 188 |
-
upload_db_to_hf(specific_file=DATA_FILE)
|
| 189 |
-
except Exception as e:
|
| 190 |
-
logging.error(f"Error saving data to {DATA_FILE}: {e}", exc_info=True)
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
LANDING_TEMPLATE = '''
|
| 194 |
-
<!DOCTYPE html>
|
| 195 |
-
<html lang="ru">
|
| 196 |
-
<head>
|
| 197 |
-
<meta charset="UTF-8">
|
| 198 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 199 |
-
<title>ОсОО "Раина" - Вентиляция и Кондиционирование</title>
|
| 200 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 201 |
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap" rel="stylesheet">
|
| 202 |
-
<style>
|
| 203 |
-
:root {
|
| 204 |
-
--dark-bg: #1a1d24;
|
| 205 |
-
--card-bg: #2a2d35;
|
| 206 |
-
--text-primary: #f0f0f0;
|
| 207 |
-
--text-secondary: #a0a0b0;
|
| 208 |
-
--accent-purple: #9b59b6;
|
| 209 |
-
--accent-blue: #3498db;
|
| 210 |
-
--accent-gradient: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
|
| 211 |
-
}
|
| 212 |
-
* { margin: 0; padding: 0; box-sizing: border-box; scroll-behavior: smooth; }
|
| 213 |
-
body { font-family: 'Montserrat', sans-serif; background-color: var(--dark-bg); color: var(--text-primary); line-height: 1.7; }
|
| 214 |
-
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
|
| 215 |
-
.section { padding: 80px 0; }
|
| 216 |
-
.section-header { text-align: center; margin-bottom: 50px; }
|
| 217 |
-
.section-header h2 { font-size: 2.8rem; font-weight: 700; color: var(--text-primary); position: relative; display: inline-block; }
|
| 218 |
-
.section-header h2::after { content: ''; display: block; width: 60px; height: 4px; background: var(--accent-gradient); margin: 10px auto 0; border-radius: 2px; }
|
| 219 |
-
.grid-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }
|
| 220 |
-
.two-column-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; align-items: center; }
|
| 221 |
-
@media (max-width: 992px) { .two-column-layout { grid-template-columns: 1fr; } .two-column-layout .image-column { order: -1; } }
|
| 222 |
-
.image-column img { width: 100%; height: auto; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
|
| 223 |
-
.text-column h3 { font-size: 2rem; margin-bottom: 20px; }
|
| 224 |
-
.text-column p { color: var(--text-secondary); margin-bottom: 15px; }
|
| 225 |
-
.card { background: var(--card-bg); padding: 30px; border-radius: 12px; text-align: center; transition: transform 0.3s, box-shadow 0.3s; border: 1px solid #3a3d45; }
|
| 226 |
-
.card:hover { transform: translateY(-10px); box-shadow: 0 15px 35px rgba(0,0,0,0.4); }
|
| 227 |
-
.card .icon { font-size: 3rem; margin-bottom: 20px; background: -webkit-linear-gradient(135deg, var(--accent-purple), var(--accent-blue)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 228 |
-
.card h4 { font-size: 1.4rem; margin-bottom: 15px; }
|
| 229 |
-
.card p { color: var(--text-secondary); font-size: 0.95rem; }
|
| 230 |
-
|
| 231 |
-
/* Header */
|
| 232 |
-
header { position: fixed; top: 0; left: 0; width: 100%; background: rgba(26, 29, 36, 0.8); backdrop-filter: blur(10px); z-index: 1000; transition: background 0.3s; }
|
| 233 |
-
.navbar { display: flex; justify-content: space-between; align-items: center; height: 70px; }
|
| 234 |
-
.logo { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); text-decoration: none; }
|
| 235 |
-
.nav-links { list-style: none; display: flex; gap: 30px; }
|
| 236 |
-
.nav-links a { color: var(--text-primary); text-decoration: none; font-weight: 500; transition: color 0.3s; }
|
| 237 |
-
.nav-links a:hover, .nav-links a.active { color: var(--accent-purple); }
|
| 238 |
-
.menu-toggle { display: none; font-size: 1.5rem; color: var(--text-primary); cursor: pointer; }
|
| 239 |
-
@media(max-width: 768px) {
|
| 240 |
-
.nav-links { position: absolute; top: 70px; left: 0; width: 100%; background: var(--card-bg); flex-direction: column; align-items: center; padding: 20px 0; gap: 20px; transform: translateY(-120%); transition: transform 0.3s ease-in-out; }
|
| 241 |
-
.nav-links.active { transform: translateY(0); }
|
| 242 |
-
.menu-toggle { display: block; }
|
| 243 |
-
}
|
| 244 |
-
|
| 245 |
-
/* Hero Section */
|
| 246 |
-
#hero { height: 100vh; display: flex; align-items: center; background: url('https://i.imgur.com/G5gE3Jv.jpeg') no-repeat center center/cover; position: relative; }
|
| 247 |
-
#hero::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, rgba(26, 29, 36, 0.95), rgba(26, 29, 36, 0.6)); }
|
| 248 |
-
.hero-content { position: relative; z-index: 1; }
|
| 249 |
-
.hero-content h1 { font-size: 3.5rem; font-weight: 700; margin-bottom: 20px; line-height: 1.2; }
|
| 250 |
-
.hero-content .highlight { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 251 |
-
.hero-content p { font-size: 1.2rem; max-width: 600px; color: var(--text-secondary); margin-bottom: 30px; }
|
| 252 |
-
.cta-button { display: inline-block; padding: 15px 30px; background: var(--accent-gradient); color: white; text-decoration: none; border-radius: 50px; font-weight: 700; transition: transform 0.3s, box-shadow 0.3s; }
|
| 253 |
-
.cta-button:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(155, 89, 182, 0.3); }
|
| 254 |
-
|
| 255 |
-
/* Equipment Section */
|
| 256 |
-
.filter-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; margin-bottom: 40px; }
|
| 257 |
-
.filter-btn { padding: 10px 20px; border: 1px solid var(--accent-purple); color: var(--accent-purple); background: transparent; border-radius: 50px; cursor: pointer; transition: all 0.3s; }
|
| 258 |
-
.filter-btn.active, .filter-btn:hover { background: var(--accent-purple); color: white; }
|
| 259 |
-
.equipment-item { display: none; flex-direction: column; background: var(--card-bg); border-radius: 12px; overflow: hidden; border: 1px solid #3a3d45; }
|
| 260 |
-
.equipment-item.visible { display: flex; animation: fadeIn 0.5s; }
|
| 261 |
-
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
|
| 262 |
-
.equipment-img { width: 100%; height: 250px; background-color: #fff; display: flex; justify-content: center; align-items: center; }
|
| 263 |
-
.equipment-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
|
| 264 |
-
.equipment-info { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
|
| 265 |
-
.equipment-info h4 { font-size: 1.2rem; margin-bottom: 10px; flex-grow: 1; }
|
| 266 |
-
.equipment-info p { font-size: 0.9rem; color: var(--text-secondary); }
|
| 267 |
-
|
| 268 |
-
/* Projects Section */
|
| 269 |
-
.project-card { background: var(--card-bg); border-radius: 12px; overflow: hidden; border: 1px solid #3a3d45; }
|
| 270 |
-
.project-card img { width: 100%; height: 200px; object-fit: cover; }
|
| 271 |
-
.project-card-content { padding: 25px; }
|
| 272 |
-
.project-card-content h4 { font-size: 1.3rem; margin-bottom: 10px; }
|
| 273 |
-
.project-card-content p { color: var(--text-secondary); font-size: 0.95rem; }
|
| 274 |
-
|
| 275 |
-
/* Advantages Section */
|
| 276 |
-
.advantage-item { display: flex; align-items: flex-start; gap: 20px; background: var(--card-bg); padding: 25px; border-radius: 12px; border: 1px solid #3a3d45; }
|
| 277 |
-
.advantage-item .icon { font-size: 2.5rem; margin-top: 5px; }
|
| 278 |
-
|
| 279 |
-
/* Contact Section */
|
| 280 |
-
#contacts { background-color: var(--card-bg); }
|
| 281 |
-
.contact-info p { font-size: 1.1rem; }
|
| 282 |
-
.contact-info a { color: var(--accent-blue); text-decoration: none; }
|
| 283 |
-
|
| 284 |
-
/* Footer */
|
| 285 |
-
footer { padding: 30px 0; text-align: center; color: var(--text-secondary); border-top: 1px solid #3a3d45; margin-top: 50px; }
|
| 286 |
-
</style>
|
| 287 |
-
</head>
|
| 288 |
-
<body>
|
| 289 |
-
<header>
|
| 290 |
-
<div class="container">
|
| 291 |
-
<nav class="navbar">
|
| 292 |
-
<a href="#hero" class="logo">ОсОО "Раина"</a>
|
| 293 |
-
<ul class="nav-links">
|
| 294 |
-
<li><a href="#about">О нас</a></li>
|
| 295 |
-
<li><a href="#services">Услуги</a></li>
|
| 296 |
-
<li><a href="#turnkey">Под ключ</a></li>
|
| 297 |
-
<li><a href="#equipment">Оборудование</a></li>
|
| 298 |
-
<li><a href="#projects">Проекты</a></li>
|
| 299 |
-
<li><a href="#contacts">Контакты</a></li>
|
| 300 |
-
</ul>
|
| 301 |
-
<div class="menu-toggle"><i class="fas fa-bars"></i></div>
|
| 302 |
-
</nav>
|
| 303 |
-
</div>
|
| 304 |
-
</header>
|
| 305 |
-
|
| 306 |
-
<main>
|
| 307 |
-
<section id="hero">
|
| 308 |
-
<div class="container">
|
| 309 |
-
<div class="hero-content">
|
| 310 |
-
<h1>ОсОО "Раина": Ваш <span class="highlight">Партнер</span><br>в Вентиляции и Кондиционировании</h1>
|
| 311 |
-
<p>Обладая 15-летним опытом, мы предлагаем комплексные решения, которые обеспечивают комфорт и здоровье в любом помещении.</p>
|
| 312 |
-
<a href="#contacts" class="cta-button">Связаться с нами</a>
|
| 313 |
-
</div>
|
| 314 |
-
</div>
|
| 315 |
-
</section>
|
| 316 |
-
|
| 317 |
-
<section id="about" class="section">
|
| 318 |
-
<div class="container">
|
| 319 |
-
<div class="section-header"><h2>О Нашей Компании</h2></div>
|
| 320 |
-
<div class="two-column-layout">
|
| 321 |
-
<div class="image-column">
|
| 322 |
-
<img src="https://i.imgur.com/k6w71i8.jpeg" alt="Команда ОсОО Раина">
|
| 323 |
-
</div>
|
| 324 |
-
<div class="text-column">
|
| 325 |
-
<h3>Основание и История</h3>
|
| 326 |
-
<p>Компания "Раина" была основана в 2009 году. За эти годы мы зарекомендовали себя как надежный партнер, стремящийся к инновациям и совершенству в области климатических решений. Наш путь отмечен постоянным ростом и развитием.</p>
|
| 327 |
-
<h3>Наша Миссия</h3>
|
| 328 |
-
<p>Наша миссия — создание оптимального микроклимата для наших клиентов, обеспечивающего комфорт, здоровье и высокую производительность. Мы стремимся к тому, чтобы каждое помещение, оборудованное нашими системами, было источником чистого и свежего воздуха.</p>
|
| 329 |
-
</div>
|
| 330 |
-
</div>
|
| 331 |
-
</div>
|
| 332 |
-
</section>
|
| 333 |
-
|
| 334 |
-
<section id="services" class="section">
|
| 335 |
-
<div class="container">
|
| 336 |
-
<div class="section-header"><h2>Наши Услуги</h2></div>
|
| 337 |
-
<div class="grid-layout">
|
| 338 |
-
<div class="card">
|
| 339 |
-
<div class="icon"><i class="fas fa-drafting-compass"></i></div>
|
| 340 |
-
<h4>Проектирование</h4>
|
| 341 |
-
<p>Мы выполняем точные расчеты, создаем детализированные 3D-модели и подготавливаем всю необходимую проектную документацию.</p>
|
| 342 |
-
</div>
|
| 343 |
-
<div class="card">
|
| 344 |
-
<div class="icon"><i class="fas fa-hard-hat"></i></div>
|
| 345 |
-
<h4>Монтаж</h4>
|
| 346 |
-
<p>Осуществляем профессиональную установку всех типов систем HVAC, от бытовых кондиционеров до сложных промышленных вентиляционных систем.</p>
|
| 347 |
-
</div>
|
| 348 |
-
<div class="card">
|
| 349 |
-
<div class="icon"><i class="fas fa-tools"></i></div>
|
| 350 |
-
<h4>Сервис и Обслуживание</h4>
|
| 351 |
-
<p>Предлагаем полный спектр услуг по плановому техническому обслуживанию и аварийному ремонту. Наша служба поддержки работает 24/7.</p>
|
| 352 |
-
</div>
|
| 353 |
-
<div class="card">
|
| 354 |
-
<div class="icon"><i class="fas fa-sync-alt"></i></div>
|
| 355 |
-
<h4>Модернизация</h4>
|
| 356 |
-
<p>Помогаем повысить энергоэффективность существующих систем, внедряя современные решения и компоненты для снижения расходов.</p>
|
| 357 |
-
</div>
|
| 358 |
-
</div>
|
| 359 |
-
</div>
|
| 360 |
-
</section>
|
| 361 |
-
|
| 362 |
-
<section id="turnkey" class="section" style="background-color: #20232a;">
|
| 363 |
-
<div class="container">
|
| 364 |
-
<div class="section-header"><h2>Услуги под ключ</h2></div>
|
| 365 |
-
{% if turnkey_services %}
|
| 366 |
-
<div class="grid-layout">
|
| 367 |
-
{% for service in turnkey_services %}
|
| 368 |
-
<div class="card">
|
| 369 |
-
<div class="icon"><i class="{{ service.icon or 'fas fa-star' }}"></i></div>
|
| 370 |
-
<h4>{{ service.title }}</h4>
|
| 371 |
-
<p>{{ service.description }}</p>
|
| 372 |
-
</div>
|
| 373 |
-
{% endfor %}
|
| 374 |
-
</div>
|
| 375 |
-
{% else %}
|
| 376 |
-
<p style="text-align:center; color: var(--text-secondary);">Информация об услугах "под ключ" скоро появится. Свяжитесь с нами для уточнения деталей.</p>
|
| 377 |
-
{% endif %}
|
| 378 |
-
</div>
|
| 379 |
-
</section>
|
| 380 |
-
|
| 381 |
-
<section id="equipment" class="section">
|
| 382 |
-
<div class="container">
|
| 383 |
-
<div class="section-header"><h2>Наше Оборудование</h2></div>
|
| 384 |
-
{% if equipment %}
|
| 385 |
-
<div class="filter-buttons">
|
| 386 |
-
<button class="filter-btn active" data-filter="all">Все категории</button>
|
| 387 |
-
{% for category in categories %}
|
| 388 |
-
<button class="filter-btn" data-filter="{{ category }}">{{ category }}</button>
|
| 389 |
-
{% endfor %}
|
| 390 |
-
</div>
|
| 391 |
-
<div class="grid-layout" id="equipment-grid">
|
| 392 |
-
{% for item in equipment %}
|
| 393 |
-
<div class="equipment-item" data-category="{{ item.get('category', 'Без категории') }}">
|
| 394 |
-
<div class="equipment-img">
|
| 395 |
-
{% if item.get('photos') and item['photos']|length > 0 %}
|
| 396 |
-
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ item['photos'][0] }}" alt="{{ item['name'] }}">
|
| 397 |
-
{% else %}
|
| 398 |
-
<img src="https://via.placeholder.com/300x250.png?text=No+Image" alt="No Image">
|
| 399 |
-
{% endif %}
|
| 400 |
-
</div>
|
| 401 |
-
<div class="equipment-info">
|
| 402 |
-
<h4>{{ item.name }}</h4>
|
| 403 |
-
<p>{{ item.description }}</p>
|
| 404 |
-
</div>
|
| 405 |
-
</div>
|
| 406 |
-
{% endfor %}
|
| 407 |
-
</div>
|
| 408 |
-
{% else %}
|
| 409 |
-
<p style="text-align:center; color: var(--text-secondary);">Каталог оборудования находится в стадии наполнения. Свяжитесь с нами для подбора необходимой техники.</p>
|
| 410 |
-
{% endif %}
|
| 411 |
-
</div>
|
| 412 |
-
</section>
|
| 413 |
-
|
| 414 |
-
<section id="projects" class="section" style="background-color: #20232a;">
|
| 415 |
-
<div class="container">
|
| 416 |
-
<div class="section-header"><h2>Реализованные Проекты</h2></div>
|
| 417 |
-
<div class="grid-layout">
|
| 418 |
-
<div class="project-card">
|
| 419 |
-
<img src="https://i.imgur.com/gK9J63s.jpeg" alt="Деловой Центр">
|
| 420 |
-
<div class="project-card-content">
|
| 421 |
-
<h4>Деловой Центр "Заря"</h4>
|
| 422 |
-
<p>Проектирование и монтаж VRF-системы для 15 000 м² офисных площадей, обеспечивающей индивидуальный контроль климата.</p>
|
| 423 |
-
</div>
|
| 424 |
-
</div>
|
| 425 |
-
<div class="project-card">
|
| 426 |
-
<img src="https://i.imgur.com/Kj7iN7O.jpeg" alt="Производственный Цех">
|
| 427 |
-
<div class="project-card-content">
|
| 428 |
-
<h4>Производственный Цех "Техно"</h4>
|
| 429 |
-
<p>Разработка и установка комплексной системы промышленной вентиляции, обеспечивающей оптимальные условия труда.</p>
|
| 430 |
-
</div>
|
| 431 |
-
</div>
|
| 432 |
-
<div class="project-card">
|
| 433 |
-
<img src="https://i.imgur.com/gGj4jGq.jpeg" alt="Гостиница">
|
| 434 |
-
<div class="project-card-content">
|
| 435 |
-
<h4>Гостиница "Аврора"</h4>
|
| 436 |
-
<p>Внедрение центральной системы кондиционирования для 120 номеров, гарантирующей комфорт и свежий воздух для гостей.</p>
|
| 437 |
-
</div>
|
| 438 |
-
</div>
|
| 439 |
-
<div class="project-card">
|
| 440 |
-
<img src="https://i.imgur.com/2Yc4W5G.jpeg" alt="Медицинский Центр">
|
| 441 |
-
<div class="project-card-content">
|
| 442 |
-
<h4>Медицинский Центр "Здоровье"</h4>
|
| 443 |
-
<p>Создание "чистых помещений" класса ISO 7 c высокоэффективной фильтрацией воздуха, критически важных для медучреждений.</p>
|
| 444 |
-
</div>
|
| 445 |
-
</div>
|
| 446 |
-
</div>
|
| 447 |
-
</div>
|
| 448 |
-
</section>
|
| 449 |
-
|
| 450 |
-
<section id="advantages" class="section">
|
| 451 |
-
<div class="container">
|
| 452 |
-
<div class="section-header"><h2>Наши Преимущества</h2></div>
|
| 453 |
-
<div class="grid-layout" style="grid-template-columns: 1fr;">
|
| 454 |
-
<div class="advantage-item">
|
| 455 |
-
<div class="icon"><i class="fas fa-cogs"></i></div>
|
| 456 |
-
<div>
|
| 457 |
-
<h4>Комплексный Подход</h4>
|
| 458 |
-
<p>От детального аудита существующих систем до постгарантийного сервиса — мы сопровождаем вас на каждом этапе проекта, обеспечивая бесперебойную работу.</p>
|
| 459 |
-
</div>
|
| 460 |
-
</div>
|
| 461 |
-
<div class="advantage-item">
|
| 462 |
-
<div class="icon"><i class="fas fa-shield-alt"></i></div>
|
| 463 |
-
<div>
|
| 464 |
-
<h4>Гарантия Качества</h4>
|
| 465 |
-
<p>Мы уверены в качестве наших услуг и предоставляем гарантию на выполненные работы до 5 лет, подтверждая нашу ответственность и надежность.</p>
|
| 466 |
-
</div>
|
| 467 |
-
</div>
|
| 468 |
-
<div class="advantage-item">
|
| 469 |
-
<div class="icon"><i class="fas fa-dollar-sign"></i></div>
|
| 470 |
-
<div>
|
| 471 |
-
<h4>Экономия</h4>
|
| 472 |
-
<p>Наши решения позволяют оптимизировать затраты на эксплуатацию систем до 30%, благодаря внедрению энергоэффективных технологий и рациональному подходу.</p>
|
| 473 |
-
</div>
|
| 474 |
-
</div>
|
| 475 |
-
<div class="advantage-item">
|
| 476 |
-
<div class="icon"><i class="far fa-clock"></i></div>
|
| 477 |
-
<div>
|
| 478 |
-
<h4>Оперативность</h4>
|
| 479 |
-
<p>Мы ценим ваше время. Среднее время реагирования на заявку составляет всего 2 часа, обеспечивая быстрое решение любых вопросов.</p>
|
| 480 |
-
</div>
|
| 481 |
-
</div>
|
| 482 |
-
</div>
|
| 483 |
-
</div>
|
| 484 |
-
</section>
|
| 485 |
-
|
| 486 |
-
<section id="contacts" class="section">
|
| 487 |
-
<div class="container text-column" style="text-align: center;">
|
| 488 |
-
<div class="section-header"><h2>Контакты</h2></div>
|
| 489 |
-
<p>Благодарим вас за внимание к нашей презентации.<br>Мы готовы стать вашим надежн��м партнером в создании идеального климата.</p>
|
| 490 |
-
<div class="contact-info" style="margin-top: 30px;">
|
| 491 |
-
<p style="font-size: 1.4rem; font-weight: 500;">Свяжитесь с нами по номеру: <a href="tel:+996773901313">+(996) 773 901 313</a></p>
|
| 492 |
-
<div style="margin-top: 20px; color: var(--text-secondary);">
|
| 493 |
-
<p>ОсОО «Раина» | ИНН 00812202110194</p>
|
| 494 |
-
<p>Юр. адрес: г. Бишкек, ул. Токольдош 3а</p>
|
| 495 |
-
</div>
|
| 496 |
-
</div>
|
| 497 |
-
</div>
|
| 498 |
-
</section>
|
| 499 |
-
</main>
|
| 500 |
-
|
| 501 |
-
<footer>
|
| 502 |
-
<div class="container">
|
| 503 |
-
<p>© {{ now.year }} {{ company_name }}. Все права защищены.</p>
|
| 504 |
-
</div>
|
| 505 |
-
</footer>
|
| 506 |
-
|
| 507 |
-
<script>
|
| 508 |
-
document.addEventListener('DOMContentLoaded', function () {
|
| 509 |
-
// Mobile Menu
|
| 510 |
-
const menuToggle = document.querySelector('.menu-toggle');
|
| 511 |
-
const navLinks = document.querySelector('.nav-links');
|
| 512 |
-
menuToggle.addEventListener('click', () => {
|
| 513 |
-
navLinks.classList.toggle('active');
|
| 514 |
-
});
|
| 515 |
-
|
| 516 |
-
// Equipment Filter
|
| 517 |
-
const filterButtons = document.querySelectorAll('.filter-btn');
|
| 518 |
-
const equipmentItems = document.querySelectorAll('.equipment-item');
|
| 519 |
-
|
| 520 |
-
if (filterButtons.length > 0) {
|
| 521 |
-
filterButtons.forEach(button => {
|
| 522 |
-
button.addEventListener('click', () => {
|
| 523 |
-
filterButtons.forEach(btn => btn.classList.remove('active'));
|
| 524 |
-
button.classList.add('active');
|
| 525 |
-
|
| 526 |
-
const filter = button.dataset.filter;
|
| 527 |
-
|
| 528 |
-
equipmentItems.forEach(item => {
|
| 529 |
-
if (filter === 'all' || item.dataset.category === filter) {
|
| 530 |
-
item.classList.add('visible');
|
| 531 |
-
} else {
|
| 532 |
-
item.classList.remove('visible');
|
| 533 |
-
}
|
| 534 |
-
});
|
| 535 |
-
});
|
| 536 |
-
});
|
| 537 |
-
document.querySelector('.filter-btn[data-filter="all"]').click();
|
| 538 |
-
} else {
|
| 539 |
-
equipmentItems.forEach(item => item.classList.add('visible'));
|
| 540 |
-
}
|
| 541 |
-
});
|
| 542 |
-
</script>
|
| 543 |
-
</body>
|
| 544 |
-
</html>
|
| 545 |
-
'''
|
| 546 |
-
|
| 547 |
-
ADMIN_TEMPLATE = '''
|
| 548 |
-
<!DOCTYPE html>
|
| 549 |
-
<html lang="ru">
|
| 550 |
-
<head>
|
| 551 |
-
<meta charset="UTF-8">
|
| 552 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 553 |
-
<title>Админ-панель - ОсОО "Раина"</title>
|
| 554 |
-
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 555 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 556 |
-
<style>
|
| 557 |
-
body { font-family: 'Poppins', sans-serif; background-color: #f4f7f9; color: #333; padding: 20px; line-height: 1.6; }
|
| 558 |
-
.container { max-width: 1200px; margin: 0 auto; background-color: #fff; padding: 25px; border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,0.05); }
|
| 559 |
-
.header { padding-bottom: 15px; margin-bottom: 25px; border-bottom: 1px solid #e0e0e0; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;}
|
| 560 |
-
h1, h2, h3 { font-weight: 600; color: #34495e; margin-bottom: 15px; }
|
| 561 |
-
h1 { font-size: 1.8rem; }
|
| 562 |
-
h2 { font-size: 1.5rem; margin-top: 30px; display: flex; align-items: center; gap: 8px; }
|
| 563 |
-
h3 { font-size: 1.2rem; color: #2980b9; margin-top: 20px; }
|
| 564 |
-
.section { margin-bottom: 30px; padding: 20px; background-color: #fdfdfd; border: 1px solid #e0e0e0; border-radius: 8px; }
|
| 565 |
-
form { margin-bottom: 20px; }
|
| 566 |
-
label { font-weight: 500; margin-top: 10px; display: block; color: #666; font-size: 0.9rem;}
|
| 567 |
-
input[type="text"], input[type="number"], textarea, select { width: 100%; padding: 10px 12px; margin-top: 5px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.95rem; box-sizing: border-box; transition: border-color 0.3s ease; background-color: #fff; }
|
| 568 |
-
input:focus, textarea:focus, select:focus { border-color: #3498db; outline: none; box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1); }
|
| 569 |
-
textarea { min-height: 80px; resize: vertical; }
|
| 570 |
-
input[type="file"] { padding: 8px; background-color: #ffffff; cursor: pointer; border: 1px solid #e0e0e0;}
|
| 571 |
-
button, .button { padding: 10px 18px; border: none; border-radius: 6px; background-color: #3498db; color: white; font-weight: 500; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; margin-top: 15px; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; line-height: 1.2;}
|
| 572 |
-
button:hover, .button:hover { background-color: #2980b9; }
|
| 573 |
-
.delete-button { background-color: #e74c3c; }
|
| 574 |
-
.delete-button:hover { background-color: #c0392b; }
|
| 575 |
-
.add-button { background-color: #2ecc71; }
|
| 576 |
-
.add-button:hover { background-color: #27ae60; }
|
| 577 |
-
.item-list { display: grid; gap: 20px; }
|
| 578 |
-
.item { background: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.03); border: 1px solid #f0f0f0; }
|
| 579 |
-
.item-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
|
| 580 |
-
.edit-form-container { margin-top: 15px; padding: 20px; background: #f8f9fa; border: 1px dashed #e0e0e0; border-radius: 6px; display: none; }
|
| 581 |
-
details { background-color: #f9f9f9; border: 1px solid #e0e0e0; border-radius: 8px; margin-bottom: 20px; }
|
| 582 |
-
details > summary { cursor: pointer; font-weight: 600; color: #2980b9; display: block; padding: 15px; border-bottom: 1px solid #e0e0e0; list-style: none; }
|
| 583 |
-
.photo-preview img { max-width: 70px; max-height: 70px; border-radius: 5px; margin: 5px 5px 0 0; border: 1px solid #e0e0e0; object-fit: cover;}
|
| 584 |
-
.flex-container { display: flex; flex-wrap: wrap; gap: 20px; }
|
| 585 |
-
.flex-item { flex: 1; min-width: 350px; }
|
| 586 |
-
.message { padding: 10px 15px; border-radius: 6px; margin-bottom: 15px; font-size: 0.9rem;}
|
| 587 |
-
.message.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb;}
|
| 588 |
-
.message.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb;}
|
| 589 |
-
.message.warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
|
| 590 |
-
</style>
|
| 591 |
-
</head>
|
| 592 |
-
<body>
|
| 593 |
-
<div class="container">
|
| 594 |
-
<div class="header">
|
| 595 |
-
<h1><i class="fas fa-tools"></i> Админ-панель: {{ company_name }}</h1>
|
| 596 |
-
<a href="{{ url_for('landing_page') }}" class="button"><i class="fas fa-globe"></i> Перейти на сайт</a>
|
| 597 |
-
</div>
|
| 598 |
-
|
| 599 |
-
{% with messages = get_flashed_messages(with_categories=true) %}
|
| 600 |
-
{% if messages %}
|
| 601 |
-
{% for category, message in messages %}
|
| 602 |
-
<div class="message {{ category }}">{{ message }}</div>
|
| 603 |
-
{% endfor %}
|
| 604 |
-
{% endif %}
|
| 605 |
-
{% endwith %}
|
| 606 |
-
|
| 607 |
-
<div class="section">
|
| 608 |
-
<h2><i class="fas fa-sync-alt"></i> Синхронизация с Датацентром</h2>
|
| 609 |
-
<form method="POST" action="{{ url_for('force_upload') }}" style="display: inline;" onsubmit="return confirm('Загрузить локальные данные на сервер? Это перезапишет данные на сервере.');">
|
| 610 |
-
<button type="submit" class="button"><i class="fas fa-upload"></i> Загрузить БД</button>
|
| 611 |
-
</form>
|
| 612 |
-
<form method="POST" action="{{ url_for('force_download') }}" style="display: inline;" onsubmit="return confirm('Скачать данные с сервера? Это перезапишет ваши локальные файлы.');">
|
| 613 |
-
<button type="submit" class="button" style="background-color:#95a5a6;"><i class="fas fa-download"></i> Скачать БД</button>
|
| 614 |
-
</form>
|
| 615 |
-
</div>
|
| 616 |
-
|
| 617 |
-
<div class="flex-container">
|
| 618 |
-
<div class="flex-item">
|
| 619 |
-
<div class="section">
|
| 620 |
-
<h2><i class="fas fa-tags"></i> Категории оборудования</h2>
|
| 621 |
-
<details>
|
| 622 |
-
<summary><i class="fas fa-plus-circle"></i> Добавить категорию</summary>
|
| 623 |
-
<form method="POST">
|
| 624 |
-
<input type="hidden" name="action" value="add_category">
|
| 625 |
-
<label for="add_category_name">Название категории:</label>
|
| 626 |
-
<input type="text" id="add_category_name" name="category_name" required>
|
| 627 |
-
<button type="submit" class="add-button"><i class="fas fa-plus"></i> Добавить</button>
|
| 628 |
-
</form>
|
| 629 |
-
</details>
|
| 630 |
-
<h3>Существующие категории:</h3>
|
| 631 |
-
{% for category in categories %}
|
| 632 |
-
<div class="item" style="display: flex; justify-content: space-between; align-items: center;">
|
| 633 |
-
<span>{{ category }}</span>
|
| 634 |
-
<form method="POST" style="margin: 0;" onsubmit="return confirm('Удалить категорию \'{{ category }}\'?');">
|
| 635 |
-
<input type="hidden" name="action" value="delete_category">
|
| 636 |
-
<input type="hidden" name="category_name" value="{{ category }}">
|
| 637 |
-
<button type="submit" class="delete-button"><i class="fas fa-trash-alt"></i></button>
|
| 638 |
-
</form>
|
| 639 |
-
</div>
|
| 640 |
-
{% endfor %}
|
| 641 |
-
</div>
|
| 642 |
-
</div>
|
| 643 |
-
<div class="flex-item">
|
| 644 |
-
<div class="section">
|
| 645 |
-
<h2><i class="fas fa-star"></i> Услуги "под ключ"</h2>
|
| 646 |
-
<details>
|
| 647 |
-
<summary><i class="fas fa-plus-circle"></i> Добавить услугу</summary>
|
| 648 |
-
<form method="POST">
|
| 649 |
-
<input type="hidden" name="action" value="add_turnkey_service">
|
| 650 |
-
<label for="ts_title">Заголовок *:</label>
|
| 651 |
-
<input type="text" id="ts_title" name="title" required>
|
| 652 |
-
<label for="ts_desc">Описание *:</label>
|
| 653 |
-
<textarea id="ts_desc" name="description" required></textarea>
|
| 654 |
-
<label for="ts_icon">Иконка (Font Awesome класс, например, 'fas fa-home'):</label>
|
| 655 |
-
<input type="text" id="ts_icon" name="icon" placeholder="fas fa-cogs">
|
| 656 |
-
<button type="submit" class="add-button"><i class="fas fa-plus"></i> Добавить</button>
|
| 657 |
-
</form>
|
| 658 |
-
</details>
|
| 659 |
-
<h3>Существующие услуги:</h3>
|
| 660 |
-
{% for service in turnkey_services %}
|
| 661 |
-
<div class="item">
|
| 662 |
-
<h4><i class="{{ service.icon or 'fas fa-star' }}"></i> {{ service.title }}</h4>
|
| 663 |
-
<p>{{ service.description }}</p>
|
| 664 |
-
<div class="item-actions">
|
| 665 |
-
<button type="button" onclick="toggleEditForm('edit-ts-{{ loop.index0 }}')"><i class="fas fa-edit"></i></button>
|
| 666 |
-
<form method="POST" style="margin:0;" onsubmit="return confirm('Удалить услугу \'{{ service.title }}\'?');">
|
| 667 |
-
<input type="hidden" name="action" value="delete_turnkey_service">
|
| 668 |
-
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 669 |
-
<button type="submit" class="delete-button"><i class="fas fa-trash-alt"></i></button>
|
| 670 |
-
</form>
|
| 671 |
-
</div>
|
| 672 |
-
<div id="edit-ts-{{ loop.index0 }}" class="edit-form-container">
|
| 673 |
-
<form method="POST">
|
| 674 |
-
<input type="hidden" name="action" value="edit_turnkey_service">
|
| 675 |
-
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 676 |
-
<label>Заголовок *:</label><input type="text" name="title" value="{{ service.title }}" required>
|
| 677 |
-
<label>Описание *:</label><textarea name="description" required>{{ service.description }}</textarea>
|
| 678 |
-
<label>Иконка:</label><input type="text" name="icon" value="{{ service.icon }}">
|
| 679 |
-
<button type="submit"><i class="fas fa-save"></i> Сохранить</button>
|
| 680 |
-
</form>
|
| 681 |
-
</div>
|
| 682 |
-
</div>
|
| 683 |
-
{% endfor %}
|
| 684 |
-
</div>
|
| 685 |
-
</div>
|
| 686 |
-
</div>
|
| 687 |
-
|
| 688 |
-
<div class="section">
|
| 689 |
-
<h2><i class="fas fa-box-open"></i> Оборудование</h2>
|
| 690 |
-
<details>
|
| 691 |
-
<summary><i class="fas fa-plus-circle"></i> Добавить оборудование</summary>
|
| 692 |
-
<form method="POST" enctype="multipart/form-data">
|
| 693 |
-
<input type="hidden" name="action" value="add_equipment">
|
| 694 |
-
<label>Название *:</label><input type="text" name="name" required>
|
| 695 |
-
<label>Описание:</label><textarea name="description" rows="4"></textarea>
|
| 696 |
-
<label>Категория:</label>
|
| 697 |
-
<select name="category">
|
| 698 |
-
<option value="Без категории">Без категории</option>
|
| 699 |
-
{% for category in categories %}<option value="{{ category }}">{{ category }}</option>{% endfor %}
|
| 700 |
-
</select>
|
| 701 |
-
<label>Фотография:</label><input type="file" name="photo" accept="image/*">
|
| 702 |
-
<button type="submit" class="add-button"><i class="fas fa-plus"></i> Добавить оборудование</button>
|
| 703 |
-
</form>
|
| 704 |
-
</details>
|
| 705 |
-
<h3>Список оборудования:</h3>
|
| 706 |
-
<div class="item-list">
|
| 707 |
-
{% for item in equipment %}
|
| 708 |
-
<div class="item">
|
| 709 |
-
<div style="display: flex; gap: 15px; align-items: flex-start;">
|
| 710 |
-
<div class="photo-preview">
|
| 711 |
-
{% if item.get('photos') and item.get('photos')|length > 0 %}
|
| 712 |
-
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ item.photos[0] }}" alt="Фото">
|
| 713 |
-
{% else %}
|
| 714 |
-
<img src="https://via.placeholder.com/70x70.png?text=N/A" alt="Нет фото">
|
| 715 |
-
{% endif %}
|
| 716 |
-
</div>
|
| 717 |
-
<div style="flex-grow: 1;">
|
| 718 |
-
<h3 style="margin-top: 0; margin-bottom: 5px;">{{ item.name }}</h3>
|
| 719 |
-
<p><strong>Категория:</strong> {{ item.get('category', 'Без категории') }}</p>
|
| 720 |
-
<p><strong>Описание:</strong> {{ item.get('description', 'N/A') }}</p>
|
| 721 |
-
</div>
|
| 722 |
-
</div>
|
| 723 |
-
<div class="item-actions">
|
| 724 |
-
<button onclick="toggleEditForm('edit-eq-{{ loop.index0 }}')"><i class="fas fa-edit"></i> Редактировать</button>
|
| 725 |
-
<form method="POST" style="margin:0;" onsubmit="return confirm('Удалить оборудование \'{{ item.name }}\'?');">
|
| 726 |
-
<input type="hidden" name="action" value="delete_equipment">
|
| 727 |
-
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 728 |
-
<button type="submit" class="delete-button"><i class="fas fa-trash-alt"></i> Удалить</button>
|
| 729 |
-
</form>
|
| 730 |
-
</div>
|
| 731 |
-
<div id="edit-eq-{{ loop.index0 }}" class="edit-form-container">
|
| 732 |
-
<form method="POST" enctype="multipart/form-data">
|
| 733 |
-
<input type="hidden" name="action" value="edit_equipment">
|
| 734 |
-
<input type="hidden" name="index" value="{{ loop.index0 }}">
|
| 735 |
-
<label>Название *:</label><input type="text" name="name" value="{{ item.name }}" required>
|
| 736 |
-
<label>Описание:</label><textarea name="description">{{ item.get('description', '') }}</textarea>
|
| 737 |
-
<label>Категория:</label>
|
| 738 |
-
<select name="category">
|
| 739 |
-
{% for category in categories %}<option value="{{ category }}" {% if item.get('category') == category %}selected{% endif %}>{{ category }}</option>{% endfor %}
|
| 740 |
-
</select>
|
| 741 |
-
<label>Заменить фотографию:</label><input type="file" name="photo" accept="image/*">
|
| 742 |
-
<button type="submit"><i class="fas fa-save"></i> Сохранить</button>
|
| 743 |
-
</form>
|
| 744 |
-
</div>
|
| 745 |
-
</div>
|
| 746 |
-
{% endfor %}
|
| 747 |
-
</div>
|
| 748 |
-
</div>
|
| 749 |
-
</div>
|
| 750 |
-
<script>
|
| 751 |
-
function toggleEditForm(formId) {
|
| 752 |
-
const form = document.getElementById(formId);
|
| 753 |
-
if (form) form.style.display = form.style.display === 'block' ? 'none' : 'block';
|
| 754 |
-
}
|
| 755 |
-
</script>
|
| 756 |
-
</body>
|
| 757 |
-
</html>
|
| 758 |
-
'''
|
| 759 |
-
|
| 760 |
-
@app.route('/')
|
| 761 |
-
def landing_page():
|
| 762 |
-
data = load_data()
|
| 763 |
-
return render_template_string(
|
| 764 |
-
LANDING_TEMPLATE,
|
| 765 |
-
company_name=COMPANY_NAME,
|
| 766 |
-
now=datetime.utcnow(),
|
| 767 |
-
turnkey_services=data.get('turnkey_services', []),
|
| 768 |
-
equipment=data.get('equipment', []),
|
| 769 |
-
categories=sorted(data.get('categories', [])),
|
| 770 |
-
repo_id=REPO_ID
|
| 771 |
-
)
|
| 772 |
-
|
| 773 |
-
@app.route('/admin', methods=['GET', 'POST'])
|
| 774 |
-
def admin():
|
| 775 |
-
data = load_data()
|
| 776 |
-
equipment = data.get('equipment', [])
|
| 777 |
-
categories = data.get('categories', [])
|
| 778 |
-
turnkey_services = data.get('turnkey_services', [])
|
| 779 |
-
|
| 780 |
-
if request.method == 'POST':
|
| 781 |
-
action = request.form.get('action')
|
| 782 |
-
logging.info(f"Admin action received: {action}")
|
| 783 |
-
|
| 784 |
-
try:
|
| 785 |
-
if action == 'add_category':
|
| 786 |
-
category_name = request.form.get('category_name', '').strip()
|
| 787 |
-
if category_name and category_name not in categories:
|
| 788 |
-
categories.append(category_name)
|
| 789 |
-
data['categories'] = categories
|
| 790 |
-
save_data(data)
|
| 791 |
-
flash(f"Категория '{category_name}' добавлена.", 'success')
|
| 792 |
-
else:
|
| 793 |
-
flash("Неверное имя или категория уже существует.", 'error')
|
| 794 |
-
|
| 795 |
-
elif action == 'delete_category':
|
| 796 |
-
category_to_delete = request.form.get('category_name')
|
| 797 |
-
if category_to_delete in categories:
|
| 798 |
-
categories.remove(category_to_delete)
|
| 799 |
-
for item in equipment:
|
| 800 |
-
if item.get('category') == category_to_delete:
|
| 801 |
-
item['category'] = 'Без категории'
|
| 802 |
-
data['categories'] = categories
|
| 803 |
-
data['equipment'] = equipment
|
| 804 |
-
save_data(data)
|
| 805 |
-
flash(f"Категория '{category_to_delete}' удалена.", 'success')
|
| 806 |
-
|
| 807 |
-
elif action == 'add_equipment':
|
| 808 |
-
name = request.form.get('name', '').strip()
|
| 809 |
-
if not name:
|
| 810 |
-
flash("Название оборудования обязательно.", 'error')
|
| 811 |
-
return redirect(url_for('admin'))
|
| 812 |
-
|
| 813 |
-
new_item = {
|
| 814 |
-
'name': name,
|
| 815 |
-
'description': request.form.get('description', '').strip(),
|
| 816 |
-
'category': request.form.get('category'),
|
| 817 |
-
'photos': []
|
| 818 |
-
}
|
| 819 |
-
photo_file = request.files.get('photo')
|
| 820 |
-
if photo_file and photo_file.filename != '' and HF_TOKEN_WRITE:
|
| 821 |
-
try:
|
| 822 |
-
api = HfApi()
|
| 823 |
-
safe_name = secure_filename(name.replace(' ', '_'))[:50]
|
| 824 |
-
ext = os.path.splitext(photo_file.filename)[1].lower()
|
| 825 |
-
photo_filename = f"eq_{safe_name}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}{ext}"
|
| 826 |
-
api.upload_file(
|
| 827 |
-
path_or_fileobj=photo_file,
|
| 828 |
-
path_in_repo=f"photos/{photo_filename}",
|
| 829 |
-
repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN_WRITE
|
| 830 |
-
)
|
| 831 |
-
new_item['photos'].append(photo_filename)
|
| 832 |
-
flash("Фотография успешно загружена.", "success")
|
| 833 |
-
except Exception as e:
|
| 834 |
-
logging.error(f"Error uploading photo for new equipment: {e}")
|
| 835 |
-
flash("Ошибка при загрузке фото.", "error")
|
| 836 |
-
|
| 837 |
-
equipment.append(new_item)
|
| 838 |
-
data['equipment'] = equipment
|
| 839 |
-
save_data(data)
|
| 840 |
-
flash(f"Оборудование '{name}' добавлено.", 'success')
|
| 841 |
-
|
| 842 |
-
elif action == 'edit_equipment':
|
| 843 |
-
index = int(request.form.get('index'))
|
| 844 |
-
if 0 <= index < len(equipment):
|
| 845 |
-
item_to_edit = equipment[index]
|
| 846 |
-
item_to_edit['name'] = request.form.get('name').strip()
|
| 847 |
-
item_to_edit['description'] = request.form.get('description').strip()
|
| 848 |
-
item_to_edit['category'] = request.form.get('category')
|
| 849 |
-
|
| 850 |
-
photo_file = request.files.get('photo')
|
| 851 |
-
if photo_file and photo_file.filename != '' and HF_TOKEN_WRITE:
|
| 852 |
-
try:
|
| 853 |
-
api = HfApi()
|
| 854 |
-
if item_to_edit.get('photos'):
|
| 855 |
-
api.delete_files(repo_id=REPO_ID, paths_in_repo=[f"photos/{p}" for p in item_to_edit['photos']], repo_type="dataset", token=HF_TOKEN_WRITE)
|
| 856 |
-
|
| 857 |
-
safe_name = secure_filename(item_to_edit['name'].replace(' ', '_'))[:50]
|
| 858 |
-
ext = os.path.splitext(photo_file.filename)[1].lower()
|
| 859 |
-
photo_filename = f"eq_{safe_name}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}{ext}"
|
| 860 |
-
api.upload_file(path_or_fileobj=photo_file, path_in_repo=f"photos/{photo_filename}", repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN_WRITE)
|
| 861 |
-
item_to_edit['photos'] = [photo_filename]
|
| 862 |
-
flash("Фотография обновлена.", "success")
|
| 863 |
-
except Exception as e:
|
| 864 |
-
logging.error(f"Error updating photo: {e}")
|
| 865 |
-
flash("Ошибка при обновлении фото.", "error")
|
| 866 |
-
|
| 867 |
-
data['equipment'] = equipment
|
| 868 |
-
save_data(data)
|
| 869 |
-
flash("Оборудование обновлено.", 'success')
|
| 870 |
-
|
| 871 |
-
elif action == 'delete_equipment':
|
| 872 |
-
index = int(request.form.get('index'))
|
| 873 |
-
if 0 <= index < len(equipment):
|
| 874 |
-
deleted_item = equipment.pop(index)
|
| 875 |
-
if deleted_item.get('photos') and HF_TOKEN_WRITE:
|
| 876 |
-
try:
|
| 877 |
-
api = HfApi()
|
| 878 |
-
api.delete_files(repo_id=REPO_ID, paths_in_repo=[f"photos/{p}" for p in deleted_item['photos']], repo_type="dataset", token=HF_TOKEN_WRITE)
|
| 879 |
-
except Exception as e:
|
| 880 |
-
logging.error(f"Error deleting photo from HF: {e}")
|
| 881 |
-
data['equipment'] = equipment
|
| 882 |
-
save_data(data)
|
| 883 |
-
flash("Оборудование удалено.", 'success')
|
| 884 |
-
|
| 885 |
-
elif action == 'add_turnkey_service':
|
| 886 |
-
title = request.form.get('title', '').strip()
|
| 887 |
-
if title:
|
| 888 |
-
new_service = {
|
| 889 |
-
'title': title,
|
| 890 |
-
'description': request.form.get('description', '').strip(),
|
| 891 |
-
'icon': request.form.get('icon', 'fas fa-star').strip()
|
| 892 |
-
}
|
| 893 |
-
turnkey_services.append(new_service)
|
| 894 |
-
data['turnkey_services'] = turnkey_services
|
| 895 |
-
save_data(data)
|
| 896 |
-
flash("Новая услуга добавлена.", 'success')
|
| 897 |
-
|
| 898 |
-
elif action == 'edit_turnkey_service':
|
| 899 |
-
index = int(request.form.get('index'))
|
| 900 |
-
if 0 <= index < len(turnkey_services):
|
| 901 |
-
service = turnkey_services[index]
|
| 902 |
-
service['title'] = request.form.get('title').strip()
|
| 903 |
-
service['description'] = request.form.get('description').strip()
|
| 904 |
-
service['icon'] = request.form.get('icon').strip()
|
| 905 |
-
data['turnkey_services'] = turnkey_services
|
| 906 |
-
save_data(data)
|
| 907 |
-
flash("Услуга обновлена.", 'success')
|
| 908 |
-
|
| 909 |
-
elif action == 'delete_turnkey_service':
|
| 910 |
-
index = int(request.form.get('index'))
|
| 911 |
-
if 0 <= index < len(turnkey_services):
|
| 912 |
-
turnkey_services.pop(index)
|
| 913 |
-
data['turnkey_services'] = turnkey_services
|
| 914 |
-
save_data(data)
|
| 915 |
-
flash("Услуга удалена.", 'success')
|
| 916 |
-
|
| 917 |
-
return redirect(url_for('admin'))
|
| 918 |
-
|
| 919 |
-
except Exception as e:
|
| 920 |
-
logging.error(f"Admin action '{action}' failed: {e}", exc_info=True)
|
| 921 |
-
flash(f"Произошла ошибка: {e}", 'error')
|
| 922 |
-
return redirect(url_for('admin'))
|
| 923 |
-
|
| 924 |
-
return render_template_string(
|
| 925 |
-
ADMIN_TEMPLATE,
|
| 926 |
-
company_name=COMPANY_NAME,
|
| 927 |
-
equipment=sorted(equipment, key=lambda p: p.get('name', '').lower()),
|
| 928 |
-
categories=sorted(categories),
|
| 929 |
-
turnkey_services=turnkey_services,
|
| 930 |
-
repo_id=REPO_ID
|
| 931 |
-
)
|
| 932 |
-
|
| 933 |
-
@app.route('/force_upload', methods=['POST'])
|
| 934 |
-
def force_upload():
|
| 935 |
-
logging.info("Forcing upload to Hugging Face...")
|
| 936 |
-
upload_db_to_hf()
|
| 937 |
-
flash("Данные загружены на Hugging Face.", 'success')
|
| 938 |
-
return redirect(url_for('admin'))
|
| 939 |
-
|
| 940 |
-
@app.route('/force_download', methods=['POST'])
|
| 941 |
-
def force_download():
|
| 942 |
-
logging.info("Forcing download from Hugging Face...")
|
| 943 |
-
if download_db_from_hf():
|
| 944 |
-
flash("Данные скачаны с Hugging Face.", 'success')
|
| 945 |
-
load_data()
|
| 946 |
-
else:
|
| 947 |
-
flash("Не удалось скачать данные.", 'error')
|
| 948 |
-
return redirect(url_for('admin'))
|
| 949 |
-
|
| 950 |
-
if __name__ == '__main__':
|
| 951 |
-
logging.info("Application starting up...")
|
| 952 |
-
download_db_from_hf()
|
| 953 |
-
load_data()
|
| 954 |
-
|
| 955 |
-
if HF_TOKEN_WRITE:
|
| 956 |
-
backup_thread = threading.Thread(target=periodic_backup, daemon=True)
|
| 957 |
-
backup_thread.start()
|
| 958 |
-
logging.info("Periodic backup thread started.")
|
| 959 |
-
else:
|
| 960 |
-
logging.warning("Periodic backup NOT running (HF_TOKEN for writing not set).")
|
| 961 |
-
|
| 962 |
-
port = int(os.environ.get('PORT', 7860))
|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