sarveshpatel commited on
Commit
6309542
·
verified ·
1 Parent(s): 75f61dd

Create app/routes/health.py

Browse files
Files changed (1) hide show
  1. app/routes/health.py +42 -0
app/routes/health.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Health check and status endpoints."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from fastapi import APIRouter
6
+
7
+ from app.config import get_settings
8
+ from app.models import HealthResponse
9
+
10
+ router = APIRouter(tags=["health"])
11
+
12
+
13
+ @router.get("/health", response_model=HealthResponse)
14
+ async def health_check() -> HealthResponse:
15
+ """Health check endpoint for HuggingFace Spaces and monitoring."""
16
+ settings = get_settings()
17
+ return HealthResponse(
18
+ status="healthy",
19
+ version="1.0.0",
20
+ environment=settings.env_type.value,
21
+ code_storage_dir=settings.code_storage_dir,
22
+ max_concurrent=settings.max_concurrent_executions,
23
+ )
24
+
25
+
26
+ @router.get("/")
27
+ async def root():
28
+ """Root endpoint with server info."""
29
+ settings = get_settings()
30
+ return {
31
+ "name": "MCP Code Executor",
32
+ "version": "1.0.0",
33
+ "description": "Execute Python code via MCP protocol",
34
+ "environment": settings.env_type.value,
35
+ "endpoints": {
36
+ "health": "/health",
37
+ "mcp_tools": "/mcp/tools",
38
+ "mcp_execute": "/mcp/execute",
39
+ "tools_direct": "/tools/*",
40
+ "docs": "/docs",
41
+ },
42
+ }