After Graduate Update
This commit is contained in:
parent
b92a91ab37
commit
c6917dd85e
69 changed files with 7540 additions and 0 deletions
32
ressult/app/routes/config.py
Normal file
32
ressult/app/routes/config.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# app/routes/config.py
|
||||
"""
|
||||
Маршруты API для управления конфигурацией
|
||||
"""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
CONFIG_PATH = Path(__file__).parent.parent.parent / "config.json"
|
||||
|
||||
@router.get("/")
|
||||
async def get_config():
|
||||
"""Получение текущей конфигурации"""
|
||||
try:
|
||||
if CONFIG_PATH.exists():
|
||||
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
return {"message": "Config file not found"}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error reading config: {str(e)}")
|
||||
|
||||
@router.put("/")
|
||||
async def update_config(config_data: dict):
|
||||
"""Обновление конфигурации"""
|
||||
try:
|
||||
with open(CONFIG_PATH, 'w', encoding='utf-8') as f:
|
||||
json.dump(config_data, f, indent=4, ensure_ascii=False)
|
||||
return {"message": "Configuration updated successfully"}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error saving config: {str(e)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue