Lesson 1 of 4
FastAPI Routes
Concept
FastAPI turns Python functions into HTTP endpoints. Decorate a function with
@app.get("/path") or @app.post("/path") and it becomes an API route. The function's return value becomes the HTTP response.
m3shdup/app/main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/api/health")
async def health():
return {"status": "ok", "version": "1.0"}
# When someone visits https://commander.gritwerk.com/api/health
# they get: {"status": "ok", "version": "1.0"}
What's happening
The
@app.get line is a decorator — it registers the function as a handler for GET requests to that URL path. FastAPI automatically converts the returned dict to JSON. This is exactly how your mesh health check works.