$ show bottlepy/bottle
Bottle is a Python WSGI micro web framework distributed as a single bottle.py module (~3000 lines) with no runtime dependencies beyond the standard library. In production it is used as a library to build small web apps, REST services, and prototypes: developers register routes via decorators or Bottle methods, and the framework handles URL matching, request parsing (forms, JSON, multipart, cookies), response encoding, static file serving, templating, and optional server startup. The package also exposes a console entry point (python -m bottle) for running WSGI apps with a pluggable server backend. Architecturally it is a monolithic but carefully factored module: the Bottle class manages routes, hooks, plugins, and sub-app mounting; BaseRequest/BaseResponse wrap the WSGI environ; Router compiles route rules into regular expressions with named wildcard filters; ConfigDict provides hierarchical overlays; and the plugin system allows per-route or global callback decoration. Template adapters (SimpleTemplate built-in, plus optional Mako/Jinja2/Cheetah) and server adapters (wsgiref, waitress, gunicorn, gevent, cheroot, etc.) are swappable behind common interfaces. The test suite is comprehensive and CI runs Python 3.9-3.13. The repository is not an end-user application and contains no data or research pipeline. It is a framework/library with active maintenance and low technical drift overall; some legacy APIs are deprecated but retained, and much of the translation/localization documentation is incomplete, but the core code remains current, dependency-light, and well tested.
The LLM identified 5 files worth highlighting for reuse:
The Router class compiles URL rules into regular expressions with named wildcard filters (int, float, path, re), optimizes static routes, and supports custom filter registration. It is self-contained and deterministic, making it extractable into any URL-matching or routing subsystem.
_parse_http_header is a pure function that parses multi-valued HTTP header fields with parameters (e.g. Accept: text/html; q=0.8, application/json) into structured tuples. It is isolated from the rest of the framework and directly reusable in any HTTP tooling or protocol work.
ConfigDict._make_overlay implements a synchronized chained configuration map used for global config with route-local overrides. This is a clean, reusable pattern for layered settings in Python services where changes in one layer need to propagate to dependent layers.
_MultipartParser is a hand-rolled multipart/form-data parser that replaces the deprecated cgi.FieldStorage, supporting file uploads and streaming of large parts. It is self-contained and can be extracted for use in WSGI or ASGI request parsing without depending on the rest of Bottle.
The static_file helper provides safe file serving with path traversal protection, content-type detection, If-Modified-Since, ETag, and HTTP Range support. Although it carries a Bottle-style response API, its core logic is directly reusable by other WSGI frameworks or standalone file-serving components.