diff --git a/SRV/api/v1/settings.py b/SRV/api/v1/settings.py index ea370bf..4331550 100644 --- a/SRV/api/v1/settings.py +++ b/SRV/api/v1/settings.py @@ -1,5 +1,16 @@ -from fastapi import APIRouter, HTTPException +# api/v1/settings.py +import os +import json +import logging +import tempfile +from fastapi import APIRouter, HTTPException, Body +from starlette.responses import FileResponse from services.settings_service import SettingsService +import shutil + +# Настройка логирования +logging.basicConfig(level=logging.DEBUG) # Уровень DEBUG для детализации +logger = logging.getLogger(__name__) router = APIRouter() settings_service = SettingsService() @@ -59,4 +70,16 @@ def clear_all_data(): if success: return {"message": "Все сетевые данные успешно очищены"} except Exception as e: - raise HTTPException(status_code=500, detail=f"Ошибка очистки: {str(e)}") \ No newline at end of file + raise HTTPException(status_code=500, detail=f"Ошибка очистки: {str(e)}") + +DEVICE_PATH = "/home/merelden/main/projects/all/gonets/SRV/storage/devices/devices.json" + +@router.get("/export", response_class=FileResponse) +async def export_devices(): + if not os.path.exists(DEVICE_PATH): + return {"error": "Файл не найден"} + return FileResponse( + path=DEVICE_PATH, + filename="device.json", + media_type="application/json" + ) \ No newline at end of file