Responder¶
A familiar HTTP Service Framework for Python.
import responder
api = responder.API()
@api.route("/{greeting}")
async def greet_world(req, resp, *, greeting):
resp.text = f"{greeting}, world!"
if __name__ == '__main__':
api.run()
Powered by Starlette, uvicorn, and good intentions. The async is optional.
The Idea¶
If you’ve ever used Flask, the routing will look familiar. If you’ve used Falcon, the request/response pattern will click immediately. And if you’ve used Requests — well, you’ll feel right at home.
Responder takes these ideas and brings them together. Every view receives a request and a response. You read from one and write to the other. No return values, no special response classes, no boilerplate.
resp.textsends text.resp.htmlsends HTML.resp.mediasends JSON.resp.file("path")serves a file.resp.contentsends raw bytes.req.headersis case-insensitive.req.paramsholds query parameters.resp.status_code,req.method,req.url— the familiar ones.
Set resp.media to a dict and the right thing happens. If the client
asks for YAML, it gets YAML. Content negotiation is automatic.
Responder and FastAPI are siblings — both built on Starlette, both born around the same time, both part of the push that made ASGI the future of Python web services. FastAPI went deep on type annotations and automatic validation. Responder went for simplicity and a mutable request/response pattern. Both projects are better for the other existing. Use whichever feels right.
This is a passion project. It exists because building a web framework from scratch is one of the best ways to understand how the web works. It’s a great fit for personal projects, prototyping, teaching, research, and anyone who values a clean API over a sprawling ecosystem. If you need battle-tested infrastructure at scale, FastAPI and Django will serve you well. If you want something small, expressive, and fun to work with — welcome.
What You Get¶
One pip install, batteries included:
Mount Flask, Django, or any WSGI/ASGI app at a subroute.
Gzip compression, HSTS, CORS, and trusted host validation.
Before-request hooks that can short-circuit for auth guards.
A test client for fast, in-process testing with pytest.
Route parameters with f-string syntax and type convertors.
Lifespan context managers for startup and shutdown logic.
Custom exception handlers for clean error responses.
GraphQL with Graphene and a built-in GraphiQL IDE.
File serving with automatic content-type detection.
Sync and async views —
asyncis always optional.Class-based views with
on_get,on_post,on_request.A pleasant API with a single import statement.
OpenAPI schema generation with Swagger UI.
A production uvicorn server, ready to deploy.
HTTP method filtering for REST APIs.
Signed cookie-based sessions.
Background tasks in a thread pool.
WebSocket support.
Installation¶
$ uv pip install responder
Python 3.10 and above. That’s it.
User Guide
- Quick Start
- Feature Tour
- Method Filtering
- Class-Based Views
- Lifespan Events
- Serving Files
- Custom Error Handling
- Before-Request Hooks
- After-Request Hooks
- WebSocket Support
- Server-Sent Events (SSE)
- GraphQL
- OpenAPI Documentation
- Route Groups
- Mounting Other Apps
- Cookies
- Cookie-Based Sessions
- Static Files
- CORS
- HSTS
- Trusted Hosts
- Request ID
- Rate Limiting
- MessagePack
- Deployment
- Testing
- API Reference
- Command Line Interface