Spaces:
Sleeping
Sleeping
Download ping.py from LogicDataSolutions/CPAChatUI: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/spaces/LogicDataSolutions/CPAChatUI/resolve/main/ping.py
- Command line
-
hf download hf://spaces/LogicDataSolutions/CPAChatUI/ping.py
-
curl -L -o ping.py https://huggingface.co/spaces/LogicDataSolutions/CPAChatUI/resolve/main/ping.py
656 Bytes
| from fastapi import FastAPI | |
| def add_ping_route(app: FastAPI, call_langflow): | |
| """ | |
| Adds a /ping route to the given FastAPI app. | |
| Calls the provided call_langflow function with a test message to verify it's working. | |
| """ | |
| def ping(): | |
| """Simple health check that also calls the chat function.""" | |
| try: | |
| # Call the chat function with test message and empty history | |
| result = call_langflow("What is your name?", []) | |
| return {"status": "ok", "chat_result": result} | |
| except Exception as e: | |
| return {"status": "error", "detail": str(e)} |