File size: 1,039 Bytes
7e1dc81 | 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 37 38 39 40 41 42 43 | from fastapi import APIRouter, HTTPException
from fastapi.responses import HTMLResponse
from urllib.parse import quote_plus
router = APIRouter(tags=["Direct Player"], prefix="")
@router.get("/view")
async def view(url: str):
if not url:
raise HTTPException(status_code=400, detail="url required")
html = f"""
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {{
margin: 0;
background: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}}
video {{
width: 100%;
height: 100%;
object-fit: contain;
background: black;
}}
</style>
</head>
<body>
<video controls autoplay>
<source src="{url}" type="video/mp4">
</video>
</body>
</html>
"""
return HTMLResponse(content=html)
|