"""Example FastAPI application for the Streamline Gateway.""" from datetime import datetime from fastapi import FastAPI from pydantic import BaseModel app = FastAPI(title="API Example", description="A simple FastAPI app example") class Message(BaseModel): """Message model.""" text: str class MessageResponse(BaseModel): """Message response model.""" message: str timestamp: str echo: str @app.get("/") async def root() -> dict[str, str]: """Root endpoint.""" return { "message": "Welcome to the API Example!", "docs": "/docs", "health": "/health", } @app.get("/health") async def health() -> dict[str, str]: """Health check endpoint.""" return {"status": "healthy", "timestamp": datetime.now().isoformat()} @app.post("/echo") async def echo(message: Message) -> MessageResponse: """Echo the received message with a timestamp.""" return MessageResponse( message="Message received", timestamp=datetime.now().isoformat(), echo=message.text, ) @app.get("/items/{item_id}") async def read_item(item_id: int, q: str | None = None) -> dict[str, int | str | None]: """Example endpoint with path and query parameters.""" return {"item_id": item_id, "q": q}