Эскпорт данных тест
This commit is contained in:
parent
4257864b3d
commit
61c526d3ee
2 changed files with 27 additions and 4 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
|
from services.settings_service import SettingsService
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
# Настройка логирования
|
||||||
|
logging.basicConfig(level=logging.DEBUG) # Уровень DEBUG для детализации
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
settings_service = SettingsService()
|
settings_service = SettingsService()
|
||||||
|
|
@ -59,4 +70,16 @@ def clear_all_data():
|
||||||
if success:
|
if success:
|
||||||
return {"message": "Все сетевые данные успешно очищены"}
|
return {"message": "Все сетевые данные успешно очищены"}
|
||||||
except Exception as e:
|
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"
|
||||||
|
)
|
||||||
|
|
@ -18,5 +18,5 @@ app.include_router(router)
|
||||||
network_service = NetworkService()
|
network_service = NetworkService()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
uvicorn.run("main:app", host='0.0.0.0', port=8001, reload=True, ssl_keyfile="/etc/gonets/certs/gonets.key", ssl_certfile="/etc/gonets/certs/gonets.crt")
|
#uvicorn.run("main:app", host='0.0.0.0', port=8001, reload=True, ssl_keyfile="/etc/gonets/certs/gonets.key", ssl_certfile="/etc/gonets/certs/gonets.crt")
|
||||||
#uvicorn.run("main:app", host="0.0.0.0", port=8001, reload=True)
|
uvicorn.run("main:app", host="0.0.0.0", port=8001, reload=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue