Skip to content

Commit 5d09e76

Browse files
Update main.py
1 parent 78ed8d8 commit 5d09e76

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

api/main.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import requests
22

33
from fastapi import FastAPI, Response, status
4-
from fastapi import FastAPI
54
from .db import check_db_connection
65
import logging
76

@@ -10,24 +9,28 @@
109

1110
app = FastAPI()
1211

12+
1313
@app.get("/health")
1414
async def health(response: Response):
1515
logger.info("Health endpoint called")
1616
db_status = check_db_connection()
1717
if db_status:
1818
return {"status": "ok", "database": "connected"}
19-
19+
2020
response.status_code = status.HTTP_503_SERVICE_UNAVAILABLE
2121
return {"status": "error", "database": "disconnected"}
2222

23+
2324
@app.get("/run-agents")
2425
async def run_agents():
25-
try:
26-
response=requests.get("http://agents:8123/run",timeout=10)
27-
return response.json()
28-
except Exception as e:
29-
logger.exception("Error while calling agents service")
30-
return {"error": "Failed to run agents"}
26+
try:
27+
response = requests.get("http://agents:8123/run", timeout=10)
28+
return response.json()
29+
except Exception:
30+
logger.exception("Error while calling agents service")
31+
return {"error": "Failed to run agents"}
32+
33+
3134
@app.get("/ping")
3235
def ping():
33-
return{"message":"pong"}
36+
return {"message": "pong"}

0 commit comments

Comments
 (0)