MCPcopy Index your code
hub / github.com/TechifyBots/File-Stream-Bot / stream_handler

Function stream_handler

biisal/server/stream_routes.py:45–64  ·  view source on GitHub ↗
(request: web.Request)

Source from the content-addressed store, hash-verified

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