Bottle
Fast, dependency-free WSGI micro web framework for Python, distributed as a single file.
Repository Health
Technical Analysis
Bottle is a fast, simple, and lightweight WSGI micro web framework for Python. It ships as a single-file module with no dependencies beyond the Python standard library, making it trivial to vendor into a project or deploy on constrained environments.
Despite its small footprint, Bottle bundles everything needed to build web applications and REST APIs: a request-to-function router with dynamic URLs, a built-in template engine (with adapters for mako, jinja2, and cheetah), convenient access to form data, uploads, cookies and headers, and a development server plus adapters for production WSGI servers such as gunicorn, paste, and cheroot.
What You Get
- A decorator-based router (
@route,@get,@post) with support for clean, dynamic URL patterns and typed path filters - A built-in fast template engine plus first-class support for mako, jinja2, and cheetah templates
- Convenient request/response helpers for form data, file uploads, cookies, headers, and other HTTP features
- A built-in development server and ready-to-use adapters for WSGI servers like gunicorn, paste, and cheroot
- A plugin API for cross-cutting concerns (auth, database sessions, etc.) with no third-party runtime dependencies
Common Use Cases
- Building small REST APIs and microservices with minimal boilerplate
- Prototyping web applications quickly in a single file
- Embedding a lightweight HTTP interface into a larger Python application or device
Under The Hood
Architecture — Bottle is deliberately implemented as a single ~4,600-line bottle.py module. A central Bottle application object holds a Router that compiles route patterns into a matching structure and dispatches incoming WSGI environ dicts to registered callbacks. Request and response state are exposed through thread-local request/response proxies, a plugin pipeline wraps route callbacks for cross-cutting concerns, and a template layer (SimpleTemplate plus adapters) renders views. Server adapters normalize a range of WSGI HTTP servers behind one run() entry point.
Tech Stack — Pure Python targeting the standard library only, packaged via pyproject.toml. It implements the WSGI (PEP 3333) contract directly and integrates optionally with external template engines (mako, jinja2, cheetah) and production servers (gunicorn, paste, cheroot) without hard-depending on any of them.
Code Quality — Despite living in one file, the code is organized into clear sections (routing, request/response, templating, server adapters, plugins) and ships with a test/ suite exercised in CI via GitHub Actions across multiple Python versions. The single-file constraint trades some modularity for zero-install portability, a long-standing deliberate design choice.
API Design — The public API is famously approachable: a @route/@get/@post decorator model, request/response globals, and a one-call run() server launcher mean a complete app fits in a few lines. Extensive documentation on bottlepy.org and copy-ready examples keep the learning curve very low.