Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -183,6 +183,26 @@ async def health_check():
|
|
183 |
)
|
184 |
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
@app.get("/analysis", response_model=Optional[ConflictAnalysis])
|
187 |
async def get_latest_analysis():
|
188 |
"""Get the latest conflict analysis."""
|
|
|
183 |
)
|
184 |
|
185 |
|
186 |
+
@app.head("/health")
|
187 |
+
async def health_check_head():
|
188 |
+
"""Health check endpoint (HEAD method)."""
|
189 |
+
# This will use the same logic as the GET handler but won't return a response body
|
190 |
+
twitter_initialized = hasattr(twitter_service, 'client') and twitter_service.client is not None
|
191 |
+
gemini_initialized = analysis_service.model is not None
|
192 |
+
|
193 |
+
# For HEAD requests, FastAPI will strip the response body but keep status codes and headers
|
194 |
+
return HealthCheck(
|
195 |
+
status="healthy" if app_ready else "initializing",
|
196 |
+
version="1.1.0",
|
197 |
+
timestamp=datetime.now(),
|
198 |
+
last_update=last_update_time,
|
199 |
+
components_status={
|
200 |
+
"twitter_service": twitter_initialized,
|
201 |
+
"analysis_service": gemini_initialized
|
202 |
+
}
|
203 |
+
)
|
204 |
+
|
205 |
+
|
206 |
@app.get("/analysis", response_model=Optional[ConflictAnalysis])
|
207 |
async def get_latest_analysis():
|
208 |
"""Get the latest conflict analysis."""
|