How do you scaffold, write, and run a minimal FastAPI app?easy
Create a virtual environment, install fastapi and uvicorn[standard], define an app = FastAPI() instance with route decorators like @app.get, then run it with uvicorn main:app --reload. FastAPI automatically serves interactive docs at /docs (Swagger UI) and /redoc (ReDoc).
A typical setup is python3 -m venv venv, activating it, then pip install fastapi "uvicorn[standard]". uvicorn[standard] pulls in extras like uvloop and httptools for better performance, though plain uvicorn also works for learning or dev. app is the core application object, and every route is registered on it with a decorator matching the HTTP method (@app.get, @app.post, @app.put, @app.delete). Returning a plain Python dict from a route is enough — FastAPI serializes it to JSON automatically. uvicorn main:app --reload means "in main.py, use the object named app," and --reload restarts the server on code changes for local development only, never in production.