API Reference
Bottle
A fast, simple, and lightweight WSGI micro web framework for Python distributed as a single file.
Official Documentation ↗CompatibilityThis documentation covers version
v0.12. Check the official docs for the latest API surface.Installation
pip
pip install bottleMethods
No methods match this filter.
Bottle bundles routing, templating, and a dev server in one module with no dependencies.
Key Features
- Single-file, zero-dependency
- Decorator routing with dynamic parameters
- Built-in template engine and dev server
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
bottle.HTTPError(exception) — official text: “exception HTTPError — A subclass of HTTPResponse that triggers error handlers. init(status=None, body=None, exception=None, traceback=None, **more_headers)” (source: https://bottlepy.org/docs/dev/api.html#bottle.HTTPError, fetched 2026-11-08T16:03:08.4363995+08:00)bottle.HTTPResponse(exception) — official text: “exception HTTPResponse — A subclass of Response that can be raised or returned from request handlers to short-curcuit request processing and override changes made to the global request object. init(body=‘’, status=None, headers=None, **more_headers)” (source: https://bottlepy.org/docs/dev/api.html#bottle.HTTPResponse, fetched 2026-11-08T16:03:08.4363995+08:00)bottle.BottleException(exception) — official text: “exception BottleException — A base class for exceptions used by bottle.” (source: https://bottlepy.org/docs/dev/api.html#bottle.BottleException, fetched 2026-11-08T16:03:08.4363995+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T16:03:08.4363995+08:00 via WebFetch 官方 API 页面.
Bottle→ signature from https://bottlepy.org/docs/dev/api.html#bottle.Bottle; official text: “class Bottle — Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications. init(**kwargs)”@app.route→ signature from https://bottlepy.org/docs/dev/api.html#bottle.Bottle.route; official text: “route(path=None, method=‘GET’, callback=None, name=None, apply=None, skip=None, **config)”app.run→ signature from https://bottlepy.org/docs/dev/api.html#bottle.run; official text: “run(app=None, server=‘wsgiref’, host=‘127.0.0.1’, port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, config=None, **kargs)”
FAQ
- Is the built-in server production ready?
- No. Bottle states its server is for development; put the app behind a production WSGI server such as Gunicorn or Waitress.
- How do I read JSON bodies?
- Use request.json in the handler; Bottle parses the body when the content type is application/json.
- How are route parameters typed?
- Dynamic segments use <name> or typed filters like <int:id>, and Bottle applies the conversion before calling the handler.
Report a problem with this API docOpens a pre-filled issue on GitHub.