Улучшение генератора
Some checks failed
CI / backend (push) Failing after 8s
CI / frontend (push) Failing after 3s

This commit is contained in:
2025-12-01 11:45:18 +00:00
parent 043526229e
commit 6232b79ffa

View File

@@ -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"'
}
)