Spaces:
Sleeping
Sleeping
Create ping.py
Browse files
ping.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
|
| 3 |
+
def add_ping_route(app: FastAPI, chat_function):
|
| 4 |
+
"""
|
| 5 |
+
Adds a /ping route to the given FastAPI app.
|
| 6 |
+
Calls the provided chat_function to verify it's working.
|
| 7 |
+
"""
|
| 8 |
+
@app.get("/ping")
|
| 9 |
+
def ping():
|
| 10 |
+
"""Simple health check that also calls the chat function."""
|
| 11 |
+
try:
|
| 12 |
+
result = chat_function()
|
| 13 |
+
return {"status": "ok", "chat_result": result}
|
| 14 |
+
except Exception as e:
|
| 15 |
+
return {"status": "error", "detail": str(e)}
|