From 85bed30764900c2711d40094ecd36f206c4aaa4a Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 21 May 2025 16:46:36 +0800 Subject: [PATCH] Fix linting --- lightrag/api/lightrag_server.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 99fb15e5..bf4f11f5 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -479,24 +479,30 @@ def create_app(args): raise HTTPException(status_code=500, detail=str(e)) # Custom StaticFiles class for smart caching - class SmartStaticFiles(StaticFiles): # Renamed from NoCacheStaticFiles + class SmartStaticFiles(StaticFiles): # Renamed from NoCacheStaticFiles async def get_response(self, path: str, scope): response = await super().get_response(path, scope) - + if path.endswith(".html"): - response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" + response.headers["Cache-Control"] = ( + "no-cache, no-store, must-revalidate" + ) response.headers["Pragma"] = "no-cache" response.headers["Expires"] = "0" - elif "/assets/" in path: # Assets (JS, CSS, images, fonts) generated by Vite with hash in filename - response.headers["Cache-Control"] = "public, max-age=31536000, immutable" + elif ( + "/assets/" in path + ): # Assets (JS, CSS, images, fonts) generated by Vite with hash in filename + response.headers["Cache-Control"] = ( + "public, max-age=31536000, immutable" + ) # Add other rules here if needed for non-HTML, non-asset files - + # Ensure correct Content-Type if path.endswith(".js"): response.headers["Content-Type"] = "application/javascript" elif path.endswith(".css"): response.headers["Content-Type"] = "text/css" - + return response # Webui mount webui/index.html @@ -504,7 +510,9 @@ def create_app(args): static_dir.mkdir(exist_ok=True) app.mount( "/webui", - SmartStaticFiles(directory=static_dir, html=True, check_dir=True), # Use SmartStaticFiles + SmartStaticFiles( + directory=static_dir, html=True, check_dir=True + ), # Use SmartStaticFiles name="webui", )