fix: mount /uploads directory for serving media files
The media library stores uploaded files in the uploads/ directory but this wasn't being served by FastAPI. Added StaticFiles mount for /uploads path to serve user-uploaded media files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
11
main.py
11
main.py
@@ -146,6 +146,17 @@ if STATIC_DIR.exists():
|
||||
logger.info(f"Mounted static files from: {STATIC_DIR}")
|
||||
else:
|
||||
logger.warning(f"Static directory not found at {STATIC_DIR}")
|
||||
|
||||
# Mount uploads directory for user-uploaded media files
|
||||
UPLOADS_DIR = BASE_DIR / "uploads"
|
||||
if UPLOADS_DIR.exists():
|
||||
app.mount("/uploads", StaticFiles(directory=str(UPLOADS_DIR)), name="uploads")
|
||||
logger.info(f"Mounted uploads from: {UPLOADS_DIR}")
|
||||
else:
|
||||
# Create uploads directory if it doesn't exist
|
||||
UPLOADS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
app.mount("/uploads", StaticFiles(directory=str(UPLOADS_DIR)), name="uploads")
|
||||
logger.info(f"Created and mounted uploads directory: {UPLOADS_DIR}")
|
||||
# ========================================
|
||||
|
||||
# Include API router (JSON endpoints at /api/*)
|
||||
|
||||
Reference in New Issue
Block a user