Compare commits
2 commits
ee350c1852
...
1672f54e02
| Author | SHA1 | Date | |
|---|---|---|---|
| 1672f54e02 | |||
| 61c526d3ee |
1 changed files with 25 additions and 2 deletions
|
|
@ -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)}")
|
||||
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"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue