| from fastapi import FastAPI, HTTPException | |
| from pydantic import BaseModel | |
| import subprocess | |
| app = FastAPI() | |
| class VideoRequest(BaseModel): | |
| url: str | |
| output_path: str = "out/video.mp4" | |
| 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) | |