Update app.py
Browse files
app.py
CHANGED
|
@@ -552,4 +552,16 @@ async def xem_pdf(file_name: str = Query(..., description="T锚n file PDF mu峄憂
|
|
| 552 |
)
|
| 553 |
return FileResponse(file_path, media_type="application/pdf", filename=file_name)
|
| 554 |
except Exception as e:
|
| 555 |
-
raise HTTPException(status_code=404, detail=f"Kh么ng t矛m th岷 file: {file_name}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
)
|
| 553 |
return FileResponse(file_path, media_type="application/pdf", filename=file_name)
|
| 554 |
except Exception as e:
|
| 555 |
+
raise HTTPException(status_code=404, detail=f"Kh么ng t矛m th岷 file: {file_name}")
|
| 556 |
+
@app.get("/danh_sach_pdf")
|
| 557 |
+
async def danh_sach_pdf():
|
| 558 |
+
try:
|
| 559 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 560 |
+
repo_id = "doluong6/Quatest1"
|
| 561 |
+
|
| 562 |
+
all_files = list_repo_files(repo_id=repo_id, repo_type="dataset", token=HF_TOKEN)
|
| 563 |
+
pdfs = [f.split("/")[-1] for f in all_files if f.startswith("Tai_lieu/") and f.endswith(".pdf")]
|
| 564 |
+
|
| 565 |
+
return {"pdfs": pdfs}
|
| 566 |
+
except Exception as e:
|
| 567 |
+
return {"pdfs": [], "error": str(e)}
|