Skip to content

Commit cb4e9cf

Browse files
author
yashksaini-coder
committed
fix: 🐛 update health check endpoint and improve IP retrieval method
1 parent f7c84ba commit cb4e9cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def read_top_stocks(cache: RedisBackend = Depends(get_cache)):
8787
await cache.set(cache_key, json.dumps(stock_info), 5)
8888
return stock_info
8989

90-
@app.get("health/") # Changed to GET since it's retrieving status
90+
@app.get("/health") # Changed to GET since it's retrieving status
9191
async def health_check():
9292
try:
9393
return {
@@ -96,8 +96,9 @@ async def health_check():
9696
"uptime": "OK",
9797
"api": {
9898
"groq_api": "connected" if GROQ_API_KEY else "not configured",
99+
"redis_cache": "connected" if REDIS_URL else "not configured",
99100
},
100-
"ip": requests.client.host,
101+
"ip": requests.get('https://api.ipify.org').text,
101102
"services": {
102103
"top_stocks": app.url_path_for("read_top_stocks"),
103104
"chat": app.url_path_for("chat"),
@@ -117,7 +118,7 @@ def chat(query: str):
117118
"""
118119
API endpoint to handle user investment-related questions and return AI-generated insights.
119120
"""
120-
121+
121122
try:
122123
answer = groq_chat(query)
123124
return answer

0 commit comments

Comments
 (0)