doniramdani820 commited on
Commit
def733d
Β·
verified Β·
1 Parent(s): 3e35cb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,7 +1,7 @@
1
  # app.py - Main entry point for Hugging Face Spaces
2
  import os
3
  import logging
4
- from server import app, initialize_models
5
 
6
  # Konfigurasi logging dasar
7
  logging.basicConfig(
@@ -12,14 +12,10 @@ logging.basicConfig(
12
  # --------------------------------------------------------------------------
13
  # PENTING: Inisialisasi model di sini agar Gunicorn bisa menjalankannya
14
  # --------------------------------------------------------------------------
15
- # Blok ini akan dieksekusi saat Gunicorn mengimpor file ini.
16
- try:
17
- initialize_models()
18
- logging.info("βœ… Models initialized successfully for Gunicorn")
19
- except Exception as e:
20
- # Jika gagal, tampilkan error dan hentikan startup agar masalahnya jelas
21
- logging.error(f"❌ FATAL: Failed to initialize models: {e}")
22
- raise
23
 
24
  # --------------------------------------------------------------------------
25
  # Blok di bawah ini hanya untuk testing lokal (dijalankan dengan `python app.py`)
@@ -31,7 +27,7 @@ if __name__ == "__main__":
31
 
32
  # Mulai aplikasi
33
  logging.info(f"πŸš€ Starting Flask development server on port {port}")
34
- # Model sudah diinisialisasi di atas
35
  app.run(
36
  host="0.0.0.0",
37
  port=port,
 
1
  # app.py - Main entry point for Hugging Face Spaces
2
  import os
3
  import logging
4
+ from server import app
5
 
6
  # Konfigurasi logging dasar
7
  logging.basicConfig(
 
12
  # --------------------------------------------------------------------------
13
  # PENTING: Inisialisasi model di sini agar Gunicorn bisa menjalankannya
14
  # --------------------------------------------------------------------------
15
+ # Model sekarang diinisialisasi secara otomatis di dalam server.py
16
+ # saat modul tersebut diimpor oleh Gunicorn dengan opsi --preload.
17
+ # Tidak perlu lagi memanggil fungsi apapun di sini.
18
+ logging.info("βœ… server.py module imported, models are initialized by Gunicorn --preload.")
 
 
 
 
19
 
20
  # --------------------------------------------------------------------------
21
  # Blok di bawah ini hanya untuk testing lokal (dijalankan dengan `python app.py`)
 
27
 
28
  # Mulai aplikasi
29
  logging.info(f"πŸš€ Starting Flask development server on port {port}")
30
+ # Model sudah diinisialisasi saat 'from server import app' dijalankan
31
  app.run(
32
  host="0.0.0.0",
33
  port=port,