Download plugins/default_play.py from Iodevsho/live-view: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/Iodevsho/live-view/resolve/main/plugins/default_play.py
- Command line
-
hf download hf://spaces/Iodevsho/live-view/plugins/default_play.py
-
curl -L -o default_play.py https://huggingface.co/spaces/Iodevsho/live-view/resolve/main/plugins/default_play.py
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="") | |
| 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) | |