Spaces:
Paused
Paused
Update config_controller.py
Browse files- config_controller.py +12 -5
config_controller.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import APIRouter, Request
|
| 2 |
from service_config import ServiceConfig
|
| 3 |
|
| 4 |
router = APIRouter()
|
|
@@ -17,13 +17,20 @@ def get_config():
|
|
| 17 |
@router.post("/update")
|
| 18 |
async def update_config(request: Request):
|
| 19 |
data = await request.json()
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
# Config'i kaydet
|
| 25 |
with open(service_config.config_path, "w", encoding="utf-8") as f:
|
| 26 |
import json
|
| 27 |
json.dump(service_config, f, indent=2)
|
| 28 |
|
| 29 |
return {"message": "Configuration updated successfully"}
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter, Request, HTTPException
|
| 2 |
from service_config import ServiceConfig
|
| 3 |
|
| 4 |
router = APIRouter()
|
|
|
|
| 17 |
@router.post("/update")
|
| 18 |
async def update_config(request: Request):
|
| 19 |
data = await request.json()
|
| 20 |
+
work_mode = data.get("work_mode")
|
| 21 |
+
cloud_token = data.get("cloud_token")
|
| 22 |
+
spark_endpoint = data.get("spark_endpoint")
|
| 23 |
+
|
| 24 |
+
if not work_mode or not spark_endpoint:
|
| 25 |
+
raise HTTPException(status_code=400, detail="work_mode and spark_endpoint cannot be empty")
|
| 26 |
+
|
| 27 |
+
service_config.work_mode = work_mode
|
| 28 |
+
service_config.cloud_token = cloud_token
|
| 29 |
+
service_config.spark_endpoint = spark_endpoint
|
| 30 |
|
|
|
|
| 31 |
with open(service_config.config_path, "w", encoding="utf-8") as f:
|
| 32 |
import json
|
| 33 |
json.dump(service_config, f, indent=2)
|
| 34 |
|
| 35 |
return {"message": "Configuration updated successfully"}
|
| 36 |
+
|