From 6232b79ffa3c8883610ebb171b8c75bf8207a272 Mon Sep 17 00:00:00 2001 From: icysanta Date: Mon, 1 Dec 2025 11:45:18 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/routes/license_routes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/routes/license_routes.py b/backend/routes/license_routes.py index 9bbcc11..f48e20c 100644 --- a/backend/routes/license_routes.py +++ b/backend/routes/license_routes.py @@ -5,6 +5,7 @@ from ..services.license_service import generate_license_file router: APIRouter = APIRouter() + @router.post("/generate", response_class=FileResponse) async def generate_license( background_tasks: BackgroundTasks, @@ -25,12 +26,19 @@ async def generate_license( # Создаём временный файл на сервере filepath, temp_dir = generate_license_file(name, version) except Exception as e: - raise HTTPException(status_code=500, detail=f"Ошибка генерации лицензии: {e}") + raise HTTPException( + status_code=500, + detail=f"Ошибка генерации лицензии: {e}" + ) + # Удаляем директорию (и файл внутри) после отправки пользователю background_tasks.add_task(temp_dir.cleanup) + # Отправляем с фиксированным именем Custom.mxtpro return FileResponse( filepath, media_type="application/octet-stream", - headers={"Content-Disposition": 'attachment; filename="Custom.mxtpro"'} + headers={ + "Content-Disposition": 'attachment; filename="Custom.mxtpro"' + } )