mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 06:46:14 +00:00
3d5f3c7e93
## Summary - **Deployment guide**: health check endpoint, Docker Compose example, Caddy reverse proxy config, Procfile pattern, production checklist - **API reference**: quick usage examples for every class (API, Request, Response, RouteGroup, BackgroundQueue, RateLimiter, status helpers) - **Feature tour**: new Pydantic validation and content negotiation sections, expanded MessagePack docs - **Testing guide**: rate limiting and mounted WSGI app test examples, Werkzeug 3.1.7 tip - **Middleware tutorial**: pure ASGI middleware example (no BaseHTTPMiddleware dependency) - **CLI guide**: environment variables section (PORT, SECRET_KEY) - **Homepage**: updated feature list with SSE, rate limiting, Pydantic, content negotiation, route groups - **Backlog**: removed already-implemented items, added current ideas +362 lines of docs, no code changes. ## Test plan - [x] `make html` builds cleanly with no warnings - [x] All 199 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Kenneth Reitz <me@kennethreitz.org> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Andreas Motl <andreas.motl@panodata.org>
101 lines
2.8 KiB
ReStructuredText
101 lines
2.8 KiB
ReStructuredText
Command Line Interface
|
|
======================
|
|
|
|
Responder installs a ``responder`` command that lets you launch
|
|
applications from the terminal. You can point it at a Python module,
|
|
a local file, or even a URL — and it will find your ``API`` instance
|
|
and start serving.
|
|
|
|
|
|
Launching from a Module
|
|
-----------------------
|
|
|
|
The most common way to run a Responder application in production. Use
|
|
Python's standard dotted module path::
|
|
|
|
$ responder run acme.app
|
|
|
|
This imports ``acme.app`` and looks for an attribute called ``api``
|
|
(a ``responder.API`` instance). It's the same import system Python
|
|
uses everywhere — your ``PYTHONPATH`` and virtual environment are
|
|
respected.
|
|
|
|
|
|
Launching from a File
|
|
---------------------
|
|
|
|
During development, you often have a single file you want to run::
|
|
|
|
$ responder run helloworld.py
|
|
|
|
This loads the file directly and starts the server. Quick and easy for
|
|
prototyping and single-file applications.
|
|
|
|
You can test it with a simple HTTP request::
|
|
|
|
$ curl http://127.0.0.1:5042/hello
|
|
hello, world!
|
|
|
|
|
|
Launching from a URL
|
|
--------------------
|
|
|
|
Responder can fetch and run a Python file from any URL — great for
|
|
demos, sharing examples, and running code from GitHub::
|
|
|
|
$ responder run https://github.com/kennethreitz/responder/raw/refs/heads/main/examples/helloworld.py
|
|
|
|
This also works with ``github://`` URLs and any filesystem protocol
|
|
supported by `fsspec <https://filesystem-spec.readthedocs.io/>`_::
|
|
|
|
$ responder run github://kennethreitz:responder@/examples/helloworld.py
|
|
|
|
Cloud storage is supported too — Azure Blob Storage, Google Cloud
|
|
Storage, S3, HDFS, SFTP, and more. Install ``fsspec[full]`` for all
|
|
protocols::
|
|
|
|
$ uv pip install 'fsspec[full]'
|
|
|
|
|
|
Custom Instance Names
|
|
---------------------
|
|
|
|
By default, Responder looks for an attribute called ``api``. If your
|
|
application uses a different name, specify it with a colon::
|
|
|
|
$ responder run acme.app:service
|
|
$ responder run myapp.py:application
|
|
|
|
For URLs, use a fragment::
|
|
|
|
$ responder run https://example.com/app.py#service
|
|
|
|
|
|
Environment Variables
|
|
---------------------
|
|
|
|
Responder automatically reads the ``PORT`` environment variable at
|
|
runtime:
|
|
|
|
- ``PORT`` — bind to ``0.0.0.0`` on this port (cloud platform convention)
|
|
|
|
When ``PORT`` is set, the server binds to all interfaces automatically.
|
|
This is how cloud platforms like Fly.io, Railway, and Heroku inject the
|
|
listen port.
|
|
|
|
For other settings like ``SECRET_KEY``, read them in your application
|
|
code and pass them to ``responder.API()``::
|
|
|
|
import os
|
|
api = responder.API(secret_key=os.environ["SECRET_KEY"])
|
|
|
|
|
|
Building Frontend Assets
|
|
-------------------------
|
|
|
|
If your project includes a JavaScript frontend with a ``package.json``,
|
|
the ``build`` subcommand runs ``npm run build``::
|
|
|
|
$ responder build
|
|
$ responder build /path/to/frontend
|