File size: 692 Bytes
325b94c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from fastapi import APIRouter, HTTPException
from fastapi.responses import HTMLResponse
from agents.books.reference_lang import (
    run_references,
)

router = APIRouter(prefix="/book", tags=["Books"])


@router.post("/reference")
async def process_book(
    book_json: dict ,
):
    try:
        if not book_json:
            raise HTTPException(status_code=400, detail="لا توجد بيانات مرسلة")

        html_content = run_references(book_json)
        return HTMLResponse(content=html_content, status_code=200)

    except HTTPException:
        raise
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"خطأ في التحويل: {str(e)}")