Spaces:
Sleeping
Sleeping
File size: 824 Bytes
a38b4f9 aec5d3a a38b4f9 7006220 a38b4f9 aec5d3a |
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 26 27 28 29 |
# app/api/v1/ppt.py
from fastapi import APIRouter, HTTPException
from fastapi.responses import FileResponse
from pydantic import BaseModel
from typing import List
from app.services.ppt_service import generate_ppt_file
router = APIRouter()
class Slide(BaseModel):
title: str
content: str
class PPTInput(BaseModel):
slides: List[Slide]
@router.post("/generate")
def generate_ppt(payload: PPTInput):
try:
ppt_path = generate_ppt_file([slide.dict() for slide in payload.slides])
filename = ppt_path.split("/")[-1]
return FileResponse(
ppt_path,
media_type="application/vnd.openxmlformats-officedocument.presentationml.presentation",
filename=filename
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
|