toanvv7 commited on
Commit
5190497
·
verified ·
1 Parent(s): 34b5961

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -20
app.py CHANGED
@@ -9,33 +9,22 @@ import config
9
 
10
  def initialize_directories():
11
  """Tạo các thư mục cần thiết nếu chúng chưa tồn tại."""
 
12
  dirs_to_create = [
13
- config.GENERATED_FILES_DIR,
14
- config.TEMP_FILES_DIR,
15
- config.BACKGROUND_MUSIC_DIR,
16
- config.STATIC_FILES_DIR
17
  ]
18
  for d in dirs_to_create:
19
  os.makedirs(d, exist_ok=True)
20
- logging.info("Các thư mục đã được khởi tạo.")
21
-
22
- def verify_assets():
23
- """Kiểm tra sự tồn tại của các file ảnh tĩnh bắt buộc."""
24
- required_assets = [
25
- config.SP_HEADER_IMAGE_PATH, config.SP_FOOTER_IMAGE_PATH,
26
- config.PC_BANNER_1_5_PATH, config.SP_HEADER_IMAGE_PATH_ENG,
27
- config.SP_FOOTER_IMAGE_PATH_ENG # Thêm file còn thiếu
28
- ]
29
- for path in required_assets:
30
- if not os.path.exists(path):
31
- logging.warning(f"Không tìm thấy file ảnh bắt buộc tại: '{path}'. Ứng dụng có thể lỗi.")
32
 
33
  if __name__ == "__main__":
 
34
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
35
 
 
36
  initialize_directories()
37
- verify_assets()
38
 
39
- logging.info("Bắt đầu khởi chạy ứng dụng Gradio...")
40
- app.launch(debug=True, share=True)
41
-
 
9
 
10
  def initialize_directories():
11
  """Tạo các thư mục cần thiết nếu chúng chưa tồn tại."""
12
+ # Chỉ cần tạo thư mục lưu kết quả và thư mục tạm
13
  dirs_to_create = [
14
+ config.RESULTS_DIR,
15
+ config.TEMP_FILES_DIR
 
 
16
  ]
17
  for d in dirs_to_create:
18
  os.makedirs(d, exist_ok=True)
19
+ logging.info("Các thư mục cần thiết đã được khởi tạo.")
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  if __name__ == "__main__":
22
+ # Cấu hình logging để dễ dàng gỡ lỗi trên Hugging Face
23
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
24
 
25
+ # Khởi tạo các thư mục lúc bắt đầu
26
  initialize_directories()
 
27
 
28
+ logging.info("Bắt đầu khởi chạy ứng dụng Gradio QuizAI...")
29
+ # debug=True hữu ích khi phát triển, có thể tắt khi đã ổn định
30
+ app.launch(debug=True)