Spaces:
Sleeping

doluong6 commited on
Commit
65c5264
·
verified ·
1 Parent(s): 272339b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -604,11 +604,24 @@ async def danh_sach_pdf():
604
  async def quy_trinh():
605
  try:
606
  HF_TOKEN = os.environ.get("HF_TOKEN")
607
- all_files = list_repo_files("doluong6/Quatest1", repo_type="dataset", token=HF_TOKEN)
608
- pdfs = [f.split("/")[-1] for f in all_files if f.startswith("Quy_trinh/") and f.lower().endswith(".pdf")]
609
- return JSONResponse(content={"pdfs": pdfs})
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  except Exception as e:
611
- raise HTTPException(status_code=500, detail=f"Lỗi khi lấy danh sách PDF: {str(e)}")
612
 
613
 
614
 
 
604
  async def quy_trinh():
605
  try:
606
  HF_TOKEN = os.environ.get("HF_TOKEN")
607
+ repo_id = "doluong6/Quatest1"
608
+
609
+ all_files = list_repo_files(
610
+ repo_id=repo_id,
611
+ repo_type="dataset",
612
+ token=HF_TOKEN
613
+ )
614
+
615
+ # Lọc các file thuộc thư mục Quy_trinh/ và có đuôi PDF, DOCX, XLSX
616
+ pdfs = [
617
+ f.split("/")[-1]
618
+ for f in all_files
619
+ if f.startswith("Quy_trinh/") and f.lower().endswith((".pdf", ".docx", ".xlsx"))
620
+ ]
621
+
622
+ return {"pdfs": pdfs}
623
  except Exception as e:
624
+ return {"pdfs": [], "error": str(e)}
625
 
626
 
627