Update app.py
Browse files
app.py
CHANGED
|
@@ -628,32 +628,16 @@ async def quy_trinh():
|
|
| 628 |
@app.get("/danh_muc_thiet_bi")
|
| 629 |
async def danh_muc_thiet_bi():
|
| 630 |
try:
|
| 631 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 632 |
-
if not HF_TOKEN:
|
| 633 |
-
raise ValueError("Thi岷縰 HF_TOKEN")
|
| 634 |
-
|
| 635 |
file_path = hf_hub_download(
|
| 636 |
repo_id="doluong6/Quatest1",
|
| 637 |
filename="Quan ly thiet bi, dung cu - 25.03.28.xlsx",
|
| 638 |
repo_type="dataset",
|
| 639 |
-
token=HF_TOKEN,
|
| 640 |
cache_dir="/tmp"
|
| 641 |
)
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
if "DUNG CU SU DUNG" not in wb.sheetnames:
|
| 646 |
-
raise ValueError("Kh么ng t矛m th岷 sheet 'DUNG CU SU DUNG'")
|
| 647 |
-
|
| 648 |
-
ws = wb["DUNG CU SU DUNG"]
|
| 649 |
-
|
| 650 |
-
data = []
|
| 651 |
-
for row in ws.iter_rows(values_only=True):
|
| 652 |
-
if any(row):
|
| 653 |
-
data.append([str(cell) if cell is not None else "" for cell in row])
|
| 654 |
-
|
| 655 |
-
return JSONResponse(content={"data": data})
|
| 656 |
-
|
| 657 |
except Exception as e:
|
| 658 |
-
return
|
|
|
|
| 659 |
|
|
|
|
| 628 |
@app.get("/danh_muc_thiet_bi")
|
| 629 |
async def danh_muc_thiet_bi():
|
| 630 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
file_path = hf_hub_download(
|
| 632 |
repo_id="doluong6/Quatest1",
|
| 633 |
filename="Quan ly thiet bi, dung cu - 25.03.28.xlsx",
|
| 634 |
repo_type="dataset",
|
| 635 |
+
token=os.environ.get("HF_TOKEN"),
|
| 636 |
cache_dir="/tmp"
|
| 637 |
)
|
| 638 |
+
df = pd.read_excel(file_path, sheet_name="DUNG CU SU DUNG")
|
| 639 |
+
return df.to_dict(orient="records")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 640 |
except Exception as e:
|
| 641 |
+
return {"error": str(e)}
|
| 642 |
+
|
| 643 |
|