File size: 476 Bytes
a2ff264
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from fastapi import APIRouter, UploadFile, File, HTTPException
from backend.services.pdfreader_service import PDFService

router = APIRouter(prefix="/pdfreader", tags=["items"])
service = PDFService()

@router.post("/upload")
async def upload_pdf(file: UploadFile = File(...)):
    if not file.filename.endswith(".pdf"):
        raise HTTPException(status_code=400, detail="Only PDF files are allowed")

    result = await service.process_uploaded_pdf(file)
    return result