Skip to content

Commit 98f59a0

Browse files
committed
refactor: Skipping static file mount if Static file not found
1 parent c19a379 commit 98f59a0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,11 @@ async def rate_limit_exception_handler(request: Request, exc: Exception) -> Resp
155155
# Register the custom exception handler for rate limits
156156
app.add_exception_handler(RateLimitExceeded, rate_limit_exception_handler)
157157

158-
# Mount static files to serve CSS, JS, and other static assets
159-
# Mount static files dynamically
158+
159+
# Mount static files dynamically to serve CSS, JS, and other static assets
160160
static_dir = Path(__file__).parent / "static"
161-
if static_dir.exists():
162-
app.mount("/static", StaticFiles(directory=static_dir), name="static")
163-
else:
164-
print(f"Warning: Static directory '{static_dir}' does not exist. Skipping static file mount.")
161+
app.mount("/static", StaticFiles(directory=static_dir), name="static")
162+
165163

166164
# Set up API analytics middleware if an API key is provided
167165
if app_analytics_key := os.getenv("API_ANALYTICS_KEY"):

0 commit comments

Comments
 (0)