ciyidogan commited on
Commit
7798d22
·
verified ·
1 Parent(s): f5ce004

Delete config_controller.py

Browse files
Files changed (1) hide show
  1. config_controller.py +0 -34
config_controller.py DELETED
@@ -1,34 +0,0 @@
1
- from fastapi import APIRouter, HTTPException, Request, Depends
2
- from config_provider import get_config, ServiceConfig
3
- from service_config import ServiceConfig
4
- import json
5
-
6
- router = APIRouter()
7
-
8
- @router.get("/get")
9
- def get_config_values(config: ServiceConfig = Depends(get_config)):
10
- return {
11
- "work_mode": config.work_mode,
12
- "cloud_token": config.cloud_token
13
- }
14
-
15
- @router.post("/update")
16
- async def update_config(request: Request, config: ServiceConfig = Depends(get_config)):
17
- data = await request.json()
18
- work_mode = data.get("work_mode")
19
- cloud_token = data.get("cloud_token")
20
-
21
- if work_mode not in ["hfcloud", "cloud", "on-premise"]:
22
- raise HTTPException(status_code=400, detail="Invalid work mode")
23
-
24
- if (work_mode in ["hfcloud", "cloud"]) and not cloud_token:
25
- raise HTTPException(status_code=400, detail="Cloud token required for selected mode")
26
-
27
- config.work_mode = work_mode
28
- config.cloud_token = cloud_token
29
-
30
- with open(config.config_path, "w", encoding="utf-8") as f:
31
- json.dump(config, f, indent=2)
32
-
33
- return {"message": "Configuration updated"}
34
-