(request: web.Request)
| 43 | |
| 44 | @routes.get(r"/watch/{path:\S+}", allow_head=True) |
| 45 | async 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) |
| 67 | async def stream_handler(request: web.Request): |
nothing calls this directly
no test coverage detected