cc-stuff/mess/stream_video.py

12 lines
327 B
Python
Raw Permalink Normal View History

# x-run: sanic stream_video:app
from sanic import Request, Sanic, Websocket
app = Sanic("CCVideoStreamer")
@app.websocket("/stream")
async def ws_stream(req: Request, ws: Websocket):
with open("./video.cani", "r") as fp:
for line in fp:
await ws.send(bytes.fromhex(line.strip()))
await ws.close()