fix: update paths and add static files support for Docker
This commit is contained in:
11
app.py
11
app.py
@@ -239,7 +239,7 @@ async def general_exception_handler(request: Request, exc: Exception):
|
||||
}, status_code=500)
|
||||
|
||||
# Инициализация шаблонов
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
# Инициализация безопасности
|
||||
security = HTTPBearer()
|
||||
@@ -253,6 +253,11 @@ SNAP_DIR = os.getenv("LOGBOARD_SNAPSHOT_DIR", "./snapshots")
|
||||
os.makedirs(SNAP_DIR, exist_ok=True)
|
||||
app.mount("/snapshots", StaticFiles(directory=SNAP_DIR), name="snapshots")
|
||||
|
||||
# serve static files directory
|
||||
STATIC_DIR = os.getenv("LOGBOARD_STATIC_DIR", "./app/static")
|
||||
os.makedirs(STATIC_DIR, exist_ok=True)
|
||||
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
||||
|
||||
# Модели данных
|
||||
class UserLogin(BaseModel):
|
||||
username: str
|
||||
@@ -541,7 +546,7 @@ def list_containers(projects: Optional[List[str]] = None, include_stopped: bool
|
||||
return items
|
||||
|
||||
# ---------- HTML ----------
|
||||
INDEX_PATH = os.getenv("LOGBOARD_INDEX_HTML", "./templates/index.html")
|
||||
INDEX_PATH = os.getenv("LOGBOARD_INDEX_HTML", "./app/templates/index.html")
|
||||
def load_index_html() -> str:
|
||||
"""Загружает HTML шаблон главной страницы"""
|
||||
with open(INDEX_PATH, "r", encoding="utf-8") as f:
|
||||
@@ -549,7 +554,7 @@ def load_index_html() -> str:
|
||||
|
||||
def load_login_html() -> str:
|
||||
"""Загружает HTML шаблон страницы входа"""
|
||||
login_path = "./templates/login.html"
|
||||
login_path = "./app/templates/login.html"
|
||||
with open(login_path, "r", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user