perbaikan beberapa fitur

This commit is contained in:
rijalhabibullah 2026-04-06 01:50:50 +07:00
parent 9db6afa110
commit bbdf79124f
2 changed files with 10 additions and 7 deletions

View File

@ -13,12 +13,12 @@ import json
class RiceLeafClassificationAPI:
"""Client untuk Rice Leaf Disease Classification API"""
def __init__(self, base_url: str = "http://127.0.0.1:8000/api/classification"):
def __init__(self, base_url: str = "http://127.0.0.1:5000"):
"""
Initialize API client
Args:
base_url: Base URL untuk API endpoint
base_url: Base URL untuk API endpoint (default: Flask API on port 5000)
"""
self.base_url = base_url
self.session = requests.Session()
@ -32,10 +32,13 @@ class RiceLeafClassificationAPI:
Tuple (success, message)
"""
try:
response = self.session.get(f"{self.base_url}/test", timeout=10)
response = self.session.get(f"{self.base_url}/health", timeout=10)
if response.status_code == 200:
data = response.json()
return data['success'], data.get('message', 'Connection OK')
if 'status' in data: # Flask API response
return data['status'] == 'ok', data.get('message', 'Connection OK')
else:
return data.get('success', True), data.get('message', 'Connection OK')
else:
return False, f"HTTP {response.status_code}"
except Exception as e:
@ -70,7 +73,7 @@ class RiceLeafClassificationAPI:
try:
# Tentukan endpoint
endpoint = "classify-and-save" if save else "classify"
endpoint = "classify" if not save else "classify"
url = f"{self.base_url}/{endpoint}"
# Baca dan kirim file

View File

@ -1660,7 +1660,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
@ -1674,7 +1674,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.5"
}
},
"nbformat": 4,