Skip to content
UPEEC

FastAPI

A modern async API framework using type hints for validation and automatic OpenAPI docs.

Easy
Comments 0
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()
class Reading(BaseModel):
    sensor: str
    value: float

@app.post("/readings")
async def add(r: Reading):
    return {"saved": r.sensor}

Run with uvicorn main:app --reload and open /docs for interactive documentation.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.