Добавление авторизации и улучшение качества кода

This commit is contained in:
2025-12-19 12:35:51 +03:00
parent 16a043843a
commit f6ac03a869
11 changed files with 836 additions and 164 deletions
+7 -13
View File
@@ -31,7 +31,13 @@ def get_info(app) -> Dict:
@router.get("/", include_in_schema=False)
async def root(request: Request, app=Depends(get_app)):
"""Эндпоинт главной страницы"""
return templates.TemplateResponse(request, "index.html", get_info(app))
return RedirectResponse("/books")
@router.get("/books", include_in_schema=False)
async def books(request: Request, app=Depends(get_app)):
"""Эндпоинт страницы выбора книг"""
return templates.TemplateResponse(request, "books.html", get_info(app))
@router.get("/auth", include_in_schema=False)
@@ -61,18 +67,6 @@ async def favicon():
)
@router.get("/static/{path:path}", include_in_schema=False)
async def serve_static(path: str):
"""Статические файлы"""
static_dir = Path(__file__).parent.parent / "static"
file_path = static_dir / path
if not file_path.is_file() or not file_path.is_relative_to(static_dir):
return JSONResponse(status_code=404, content={"error": "File not found"})
return FileResponse(file_path)
@router.get(
"/api/info",
summary="Информация о сервисе",