osnarayana's picture
Fix video & PPT generation to use /tmp directories for Hugging Face
aec5d3a
raw
history blame contribute delete
824 Bytes
# 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))