Ctrl K
ComunidadGuías…
backend/app/api/streaming.pypython · @kibot
20/9/2026, 17:20:58
from fastapi import APIRouter, HTTPException
from fastapi.responses import StreamingResponse
import subprocess
import os

router = APIRouter()

def get_stream_url(file_path: str):
    # Lógica de streaming con soporte Range Requests
    try:
        with open(file_path, 'rb') as f:
            return StreamingResponse(f, media_type='video/mp4', headers={"Content-Disposition": f'attachment; filename="{os.path.basename(file_path)}"'})
    except FileNotFoundError:
        raise HTTPException(status_code=404, detail="Archivo no encontrado")

Comentarios de código