Update app.py
Browse files
app.py
CHANGED
|
@@ -456,5 +456,36 @@ def pyc_chua_hoan_thanh():
|
|
| 456 |
|
| 457 |
return ket_qua
|
| 458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
except Exception as e:
|
| 460 |
return {"error": str(e)}
|
|
|
|
| 456 |
|
| 457 |
return ket_qua
|
| 458 |
|
| 459 |
+
except Exception as e:
|
| 460 |
+
return {"error": str(e)}
|
| 461 |
+
|
| 462 |
+
@app.get("/ty_le_dich_vu")
|
| 463 |
+
def ty_le_dich_vu():
|
| 464 |
+
try:
|
| 465 |
+
# Tải file Excel từ dataset
|
| 466 |
+
local_path = hf_hub_download(
|
| 467 |
+
repo_id=REPO_ID,
|
| 468 |
+
repo_type="dataset",
|
| 469 |
+
filename="thong_ke_dich_vu.xlsx",
|
| 470 |
+
token=HF_TOKEN,
|
| 471 |
+
cache_dir="/tmp"
|
| 472 |
+
)
|
| 473 |
+
|
| 474 |
+
wb = load_workbook(local_path, data_only=True)
|
| 475 |
+
sheet = wb.active
|
| 476 |
+
|
| 477 |
+
result = {}
|
| 478 |
+
for row in range(2, 5): # Dòng 2–4 chứa dữ liệu
|
| 479 |
+
loai = sheet[f"A{row}"].value # Cột A: "Dịch vụ"
|
| 480 |
+
ty_le = sheet[f"C{row}"].value # Cột C: "Tỷ lệ (%)"
|
| 481 |
+
if loai and ty_le is not None:
|
| 482 |
+
result[loai.strip()] = float(ty_le)
|
| 483 |
+
|
| 484 |
+
return {
|
| 485 |
+
"Kiem_dinh": result.get("KĐ", 0),
|
| 486 |
+
"Hieu_chuan": result.get("HC", 0),
|
| 487 |
+
"Do_thu_nghiem": result.get("ĐTN", 0)
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
except Exception as e:
|
| 491 |
return {"error": str(e)}
|