Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsApr 12, 2026·2 min de lecture

Starlette — The Little ASGI Framework That Shines

Starlette is a lightweight ASGI framework for building async web services in Python. It is the foundation that FastAPI is built on top of. Provides routing, middleware, WebSocket, GraphQL, background tasks, and streaming responses.

Introduction

Starlette is a lightweight ASGI framework/toolkit for building async web services in Python. Created by Tom Christie (also creator of Django REST Framework), Starlette is the foundation that FastAPI is built on top of. It provides routing, middleware, WebSocket, GraphQL (via ariadne/strawberry), background tasks, streaming responses, and test client.

What Starlette Does

  • ASGI — fully async, works with uvicorn, hypercorn, daphne
  • Routing — path parameters, Mount for sub-apps
  • Middleware — CORS, GZip, HTTPS redirect, Trusted Host
  • WebSocket — native support
  • Background tasks — fire-and-forget after response
  • Streaming — StreamingResponse for large files
  • Static files — StaticFiles mount
  • Test client — httpx-based test client
  • Event handlers — startup/shutdown lifecycle

Comparison

Framework Level Validation
Starlette Low-level ASGI Manual
FastAPI High-level (on Starlette) Pydantic
Litestar High-level ASGI msgspec/Pydantic
Django Full-stack WSGI/ASGI Django forms

FAQ

Q: Starlette vs FastAPI? A: FastAPI is essentially Starlette + Pydantic + auto-generated OpenAPI. Choose Starlette if you want more control or a lighter footprint; choose FastAPI if you want automatic docs and validation.

Sources

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires