MCPcopy Create free account
hub / github.com/VJBots/VJ-File-Store / stream_handler

Function stream_handler

TechVJ/server/stream_routes.py:44–63  ·  view source on GitHub ↗
(request: web.Request)

Source from the content-addressed store, hash-verified

42
43@routes.get(r"/watch/{path:\S+}", allow_head=True)
44async def stream_handler(request: web.Request):
45 try:
46 path = request.match_info["path"]
47 match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path)
48 if match:
49 secure_hash = match.group(1)
50 id = int(match.group(2))
51 else:
52 id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1))
53 secure_hash = request.rel_url.query.get("hash")
54 return web.Response(text=await render_page(id, secure_hash), content_type='text/html')
55 except InvalidHash as e:
56 raise web.HTTPForbidden(text=e.message)
57 except FIleNotFound as e:
58 raise web.HTTPNotFound(text=e.message)
59 except (AttributeError, BadStatusLine, ConnectionResetError):
60 pass
61 except Exception as e:
62 logging.critical(e.with_traceback(None))
63 raise web.HTTPInternalServerError(text=str(e))
64
65@routes.get(r"/{path:\S+}", allow_head=True)
66async def stream_handler(request: web.Request):

Callers

nothing calls this directly

Calls 2

render_pageFunction · 0.90
media_streamerFunction · 0.85

Tested by

no test coverage detected