From 8cd821c1eb59fbd6e00775b2ead15277a2faa41d Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 30 Jul 2026 14:47:13 +0800 Subject: [PATCH] feat: expand static_exts + make configurable via config.website.static_exts Added: pdf, json, xml, txt, csv, wasm, m4a, aac, flac, mov, avi, mkv, glb, gltf, obj, zip. Additional extensions can be configured in config.json: website.static_exts: ['.ext1', '.ext2'] --- ahserver/processorResource.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 50d84d7..3b7e45c 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -206,13 +206,18 @@ class ProcessorResource(StaticResource,Url2File): async def _handle(self,request:Request) -> StreamResponse: # Fast path for static assets: skip auth closures, i18n, url2processor, isHtml - static_exts = ('.js', '.css', '.png', '.jpg', '.jpeg', '.gif', '.ico', - '.svg', '.woff', '.woff2', '.ttf', '.eot', '.map', - '.webp', '.bmp', '.mp3', '.mp4', '.webm', '.ogg', '.wav') + config = getConfig() + _base = ('.js', '.css', '.png', '.jpg', '.jpeg', '.gif', '.ico', + '.svg', '.woff', '.woff2', '.ttf', '.eot', '.map', + '.webp', '.bmp', '.mp3', '.mp4', '.webm', '.ogg', '.wav', + '.pdf', '.json', '.xml', '.txt', '.csv', '.wasm', + '.m4a', '.aac', '.flac', '.mov', '.avi', '.mkv', + '.glb', '.gltf', '.obj', '.zip') + cfg_exts = getattr(getattr(config, 'website', None), 'static_exts', None) or [] + static_exts = tuple(list(_base) + list(cfg_exts)) path_lower = request.path.lower() if any(path_lower.endswith(ext) for ext in static_exts): # Skip fast path for virtual path prefixes (startswiths in config) - config = getConfig() skip = any(path_lower.startswith(a.leading) for a in (config.website.startswiths or [])) if not skip: self.parse_request(request)