Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,6 +137,26 @@ def init_db():
|
|
| 137 |
conn.commit()
|
| 138 |
conn.close()
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
# Gọi hàm init_db khi ứng dụng khởi động
|
| 141 |
init_db()
|
| 142 |
|
|
@@ -255,7 +275,16 @@ def bfat(case_id):
|
|
| 255 |
# Route cho trang dịch vụ
|
| 256 |
@app.route('/dichvu')
|
| 257 |
def dichvu():
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
@app.route('/lienhe')
|
| 261 |
def lienhe():
|
|
|
|
| 137 |
conn.commit()
|
| 138 |
conn.close()
|
| 139 |
|
| 140 |
+
# Tạo bảng services
|
| 141 |
+
cursor.execute('''
|
| 142 |
+
CREATE TABLE IF NOT EXISTS services (
|
| 143 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 144 |
+
name TEXT NOT NULL,
|
| 145 |
+
description TEXT NOT NULL,
|
| 146 |
+
duration TEXT NOT NULL,
|
| 147 |
+
visits_required TEXT NOT NULL,
|
| 148 |
+
before_image TEXT NOT NULL,
|
| 149 |
+
after_image TEXT NOT NULL
|
| 150 |
+
)
|
| 151 |
+
''')
|
| 152 |
+
|
| 153 |
+
# Chèn dữ liệu mẫu cho services (nếu bảng trống)
|
| 154 |
+
cursor.execute('SELECT COUNT(*) FROM services')
|
| 155 |
+
if cursor.fetchone()[0] == 0:
|
| 156 |
+
cursor.execute('''
|
| 157 |
+
INSERT INTO services (name, description, duration, visits_required, before_image, after_image) VALUES
|
| 158 |
+
('Porcelain Veneers', 'Biến đổi nụ cười của bạn với lớp phủ sứ được chế tác tùy chỉnh, trông và cảm giác hoàn toàn tự nhiên. Lớp phủ của chúng tôi được thiết kế riêng để nâng cao các đặc điểm khuôn mặt độc đáo của bạn.', '2-3 tuần', '2-3', 'https://images.unsplash.com/photo-1564078517170-9707c7a0e6b6?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80', 'https://images.unsplash.com/photo-1622253692010-333f2da6031d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80')
|
| 159 |
+
''')
|
| 160 |
# Gọi hàm init_db khi ứng dụng khởi động
|
| 161 |
init_db()
|
| 162 |
|
|
|
|
| 275 |
# Route cho trang dịch vụ
|
| 276 |
@app.route('/dichvu')
|
| 277 |
def dichvu():
|
| 278 |
+
conn = get_db_connection()
|
| 279 |
+
cursor = conn.cursor()
|
| 280 |
+
|
| 281 |
+
# Lấy thông tin dịch vụ (hiện tại lấy dịch vụ đầu tiên)
|
| 282 |
+
cursor.execute('SELECT * FROM services LIMIT 1')
|
| 283 |
+
service = cursor.fetchone()
|
| 284 |
+
service = dict(service) if service else {}
|
| 285 |
+
|
| 286 |
+
conn.close()
|
| 287 |
+
return render_template('dichvu.html', service=service)
|
| 288 |
|
| 289 |
@app.route('/lienhe')
|
| 290 |
def lienhe():
|