FastAPI

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.

main.py

Install

   1 # uv An extremely fast Python package and project manager, written in Rust.
   2 # https://docs.astral.sh/uv/getting-started/installation/
   3 curl -LsSf https://astral.sh/uv/install.sh | sh
   4 pipx install uv
   5 pip install uv
   6 uv self update
   7 pip install --upgrade uv
   8 
   9 uv add "fastapi[standard]"

   1 from fastapi import FastAPI
   2 
   3 app = FastAPI()
   4 
   5 @app.get("/")
   6 def read_root():
   7     return {"Hello": "World"}
   8 
   9 @app.get("/items/{item_id}")
  10 def read_item(item_id: int, q: str | None = None):
  11     return {"item_id": item_id, "q": q}

Run

uv run fastapi dev

FastAPI (last edited 2026-08-23 15:47:24 by vitor)