File size: 906 Bytes
8249c8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5511a6
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
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))


import sys
print(sys.path)

try:
    import moviepy.editor
    print("✅ MoviePy installed")
except Exception as e:
    print(e)