fix: serve slides assets in app

This commit is contained in:
2026-06-18 21:20:09 +03:30
parent a40721aba4
commit 3b84e1effc
3 changed files with 18 additions and 2 deletions

View File

@@ -9,5 +9,8 @@ __pycache__/
.ruff_cache/
.uvicorn.pid
docs/
docs/images/
docs/screenshots/
docs/*.pdf
docs/presentation.md
README.md

View File

@@ -10,6 +10,7 @@ RUN pip install --no-cache-dir --upgrade pip setuptools wheel -i https://package
&& pip install --no-cache-dir -r requirements.txt -i https://package-mirror.liara.ir/repository/pypi/simple
COPY app ./app
COPY docs/slides ./docs/slides
EXPOSE 8000

View File

@@ -1,7 +1,7 @@
from pathlib import Path
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.responses import FileResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from app.websocket.chat import router as chat_router
@@ -9,6 +9,7 @@ from app.websocket.manager import manager
BASE_DIR = Path(__file__).resolve().parent
STATIC_DIR = BASE_DIR / "static"
SLIDES_DIR = BASE_DIR.parent / "docs" / "slides"
app = FastAPI(title="Simple WebSocket Chatroom")
@@ -20,6 +21,17 @@ app.include_router(chat_router)
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
@app.get("/slides", include_in_schema=False)
async def slides_redirect():
"""Redirect to the static slides directory so relative asset paths work."""
return RedirectResponse(url="/slides/")
# Serves the presentation and its relative assets.
# This keeps docs/slides/index.html openable directly from the file system too.
app.mount("/slides", StaticFiles(directory=SLIDES_DIR, html=True), name="slides")
@app.get("/")
async def home():
"""Serve the chatroom GUI."""