live-view / plugins /default_play.py
GitHub Actions Bot
Sync from GitHub main branch
7e1dc81
Raw History Blame Contribute Delete
1.04 kB
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)