From c1f836152389491fac0371c09ef6fceb7f622f42 Mon Sep 17 00:00:00 2001
From: livindra
Date: Sun, 31 May 2026 13:07:17 +0700
Subject: [PATCH] fix
---
app.py | 28 ++-------------------------
templates/index.html | 46 +++++++-------------------------------------
2 files changed, 9 insertions(+), 65 deletions(-)
diff --git a/app.py b/app.py
index 588e53d..1e1ee5b 100644
--- a/app.py
+++ b/app.py
@@ -86,10 +86,9 @@ label_encoder = None
extractor = FeatureExtractor()
model_loading = False
model_loaded = False
-model_load_error = None
def _load_model_background():
- global model, scaler, label_encoder, model_loading, model_loaded, model_load_error
+ global model, scaler, label_encoder, model_loading, model_loaded
# Prevent double-loading
if model_loading or model_loaded:
@@ -102,14 +101,12 @@ def _load_model_background():
m, s, le = load_model()
model, scaler, label_encoder = m, s, le
model_loaded = True
- model_load_error = None
print('[APP] Model loaded successfully.')
except Exception as e:
model = None
scaler = None
label_encoder = None
- model_loaded = False
- model_load_error = str(e)
+ model_loaded = True # Mark as done to prevent retry loop
print(f"[APP] ❌ Background model load failed: {e}")
finally:
model_loading = False
@@ -123,27 +120,6 @@ def is_model_ready():
return model is not None and scaler is not None and label_encoder is not None
-@app.route('/api/model-status')
-def api_model_status():
- """Return the current model loading status for the homepage."""
- ready = is_model_ready()
- if ready:
- status = 'ready'
- elif model_loading:
- status = 'loading'
- elif model_load_error:
- status = 'error'
- else:
- status = 'loading'
-
- return jsonify({
- 'status': status,
- 'ready': ready,
- 'loading': model_loading,
- 'error': model_load_error,
- })
-
-
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
diff --git a/templates/index.html b/templates/index.html
index afb4099..2942e98 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -16,13 +16,15 @@
-
- {% if model_loaded %}
+ {% if model_loaded %}
+
Model siap digunakan
- {% else %}
- Model sedang dimuat, silakan tunggu...
- {% endif %}
+ {% else %}
+
+ Model sedang dimuat, silakan tunggu...
+
+ {% endif %}
@@ -98,38 +100,4 @@
border-radius: 50%;
}
-
{% endblock %}
\ No newline at end of file