Mercurial > code > home > repos > video
diff video.py @ 38:0aea9e55899b
hack in path router - dirs kind of work; putting a video in the path doesn't
author | drewp@bigasterisk.com |
---|---|
date | Wed, 04 Dec 2024 21:50:16 -0800 |
parents | 7cacfae58430 |
children | b5b29f6ef5cb |
line wrap: on
line diff
--- a/video.py Tue Dec 03 19:28:11 2024 -0800 +++ b/video.py Wed Dec 04 21:50:16 2024 -0800 @@ -30,7 +30,20 @@ async def videos(req: Request) -> JSONResponse: - subdir = req.query_params.get('subdir', '/') # danger user input + subdir = req.query_params.get('subdir', '/') + if not subdir.endswith('/'): + # raise ValueError(f'not a dir {subdir=}') + # ok we'll list the parent dir underneath + subdir = '/'.join(subdir.split('/')[:-1]) # todo move to FE + else: + subdir = subdir[:-1] + if subdir=="": + subdir = "./" + if not (subdir.startswith('/') or subdir=='./'): + raise ValueError(f'not a dir {subdir=}') + subdir = subdir[1:] + log.debug(f'videos request corrected to: {subdir=}') + vfInDir = store.findInDir(subdir) return JSONResponse({ "videos": [{