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

pippip install bottle

Methods

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 页面.

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.