Repolode
Kludex

Kludex/starlette

A lightweight ASGI framework and toolkit for building async web services and APIs in Python.

Stars
12,676
Forks
1,383
Open issues
46
Last commit
2 days ago

What is it?

Starlette is a lightweight ASGI framework and toolkit for building async web services in Python. It provides routing, HTTP and WebSocket handling, background tasks, startup and shutdown events, and middleware such as CORS, GZip, and sessions. Its components can be used on their own or together as a complete framework.

Starlette only requires anyio as a hard dependency; other features such as the test client, Jinja2 templates, form parsing, and sessions are installed as optional extras. It runs on an ASGI server such as uvicorn and is compatible with both the asyncio and trio backends.

Because its components follow the ASGI interface, middleware and mountable applications can in principle be shared with other ASGI frameworks.

Key features

  • 01Lightweight HTTP routing and request/response handling.
  • 02WebSocket support.
  • 03In-process background tasks and startup/shutdown events.
  • 04Built-in CORS, GZip, static files, and session/cookie middleware.
  • 05Test client built on httpx2.
  • 06Compatible with asyncio and trio backends.

Use cases

  • Building async JSON APIs or web services in Python.
  • Adding WebSocket endpoints to a Python backend.
  • Using individual ASGI components such as middleware or responses in a custom stack.

Quick start

  1. 1

    Install Starlette

    pip install starlette
  2. 2

    Install an ASGI server such as uvicorn

    pip install uvicorn
  3. 3

    Save the example as main.py, then run it with Uvicorn

    uvicorn main:app

Things to know

  • Starlette is a toolkit, so you need to assemble your own server and optional dependencies.
  • Some features need extra packages such as jinja2 or python-multipart.

Topics

FAQ

What is starlette?
A lightweight ASGI framework and toolkit for building async web services and APIs in Python. Starlette is a lightweight ASGI framework and toolkit for building async web services in Python. It provides routing, HTTP and WebSocket handling, background tasks, startup and shutdown events, and middleware such as CORS, GZip, and sessions. Its components can be used on their own or together as a complete framework.
Is starlette free to use? What license does it have?
starlette is open source under the BSD-3-Clause license. Check the license terms before using it in commercial products.
Is starlette still maintained?
Actively maintained. The last commit to starlette was on Oct 18, 2026.
What can I use starlette for?
Building async JSON APIs or web services in Python. Adding WebSocket endpoints to a Python backend. Using individual ASGI components such as middleware or responses in a custom stack.
How do I install starlette?
Install Starlette: pip install starlette Install an ASGI server such as uvicorn: pip install uvicorn Save the example as main.py, then run it with Uvicorn: uvicorn main:app
Where can I get starlette?
The source code and installation instructions are on GitHub: https://github.com/Kludex/starlette

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects