42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.responses import FileResponse
|
|
from pathlib import Path
|
|
|
|
# Импорт роутера
|
|
from .routes.license_routes import router as license_router # Изменено: один dot вместо двух
|
|
|
|
# Путь к корню проекта
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
|
|
def create_app() -> FastAPI:
|
|
"""
|
|
Создание и конфигурация FastAPI приложения.
|
|
Подключает роутеры и статические файлы.
|
|
"""
|
|
apps: FastAPI = FastAPI(
|
|
title="License Generator API",
|
|
description="API для генерации лицензий Custom.mxtpro",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# Подключение роутеров
|
|
apps.include_router(license_router, prefix="/api")
|
|
|
|
# Монтируем статические папки фронтенда
|
|
apps.mount("/static/css", StaticFiles(directory=BASE_DIR.parent / "frontend" / "css"), name="css")
|
|
apps.mount("/static/js", StaticFiles(directory=BASE_DIR.parent / "frontend" / "js"), name="js")
|
|
apps.mount("/static/assets", StaticFiles(directory=BASE_DIR.parent / "frontend" / "assets"), name="assets")
|
|
|
|
# Отдача главной страницы
|
|
@apps.get("/", include_in_schema=False)
|
|
def read_index() -> FileResponse:
|
|
"""
|
|
Отдает главную страницу сайта (index.html)
|
|
"""
|
|
return FileResponse(BASE_DIR.parent / "frontend" / "templates" / "index.html")
|
|
return apps
|
|
|
|
# Экземпляр приложения
|
|
app: FastAPI = create_app()
|