File size: 694 Bytes
3fcf71f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import subprocess
app = FastAPI()
class VideoRequest(BaseModel):
url: str
output_path: str = "out/video.mp4"
@app.post("/download")
def download_video(request: VideoRequest):
result = subprocess.run(['python3', 'loom-dl.py', request.url, '-o', request.output_path], capture_output=True, text=True)
if result.returncode == 0:
return {"message": "Download successful!", "output_path": request.output_path}
else:
raise HTTPException(status_code=500, detail=f"Error: {result.stderr}")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
|