Spaces:
Sleeping

doluong6 commited on
Commit
021746d
路
verified 路
1 Parent(s): f9d0902

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -21
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
- wb = openpyxl.load_workbook(file_path, data_only=True)
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 JSONResponse(status_code=500, content={"error": str(e)})
 
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