File size: 769 Bytes
d976f9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 FastAPI, UploadFile, File
from fastapi.responses import FileResponse
import os
import uuid
from utils import generate_sample_video, combine_video_audio

app = FastAPI()


@app.get("/")
async def root():
    return {"message": "FastAPI + MoviePy on Hugging Face is working."}


@app.post("/generate")
async def generate():
    output_path = generate_sample_video()
    return FileResponse(output_path, media_type="video/mp4", filename=os.path.basename(output_path))


@app.post("/combine")
async def combine(video_file: UploadFile = File(...), audio_file: UploadFile = File(...)):
    output_path = await combine_video_audio(video_file, audio_file)
    return FileResponse(output_path, media_type="video/mp4", filename=os.path.basename(output_path))