class documentation

Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications. :param catchall: If true (default), handle all exceptions. Turn off to let debugging middleware handle exceptions.

Method __call__ Each instance of :class:'Bottle' is a WSGI application.
Method __init__ Undocumented
Method add_hook Attach a callback to a hook. Three hooks are currently implemented:
Method add_route Add a route object, but do not change the :data:`Route.app` attribute.
Method close Close the application and all installed plugins.
Method default_error_handler Undocumented
Method delete Equals :meth:`route` with a ``DELETE`` method parameter.
Method error Decorator: Register an output handler for a HTTP error code
Method get Equals :meth:`route`.
Method get_url Return a string that matches a named route
Method hook Return a decorator that attaches a callback to a hook. See :meth:`add_hook` for details.
Method install Add a plugin to the list of plugins and prepare it for being applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API.
Method match Search for a matching route and return a (:class:`Route` , urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.
Method merge Merge the routes of another :class:`Bottle` application or a list of :class:`Route` objects into this application. The routes keep their 'owner', meaning that the :data:`Route.app` attribute is not changed...
Method mount Mount an application (:class:`Bottle` or plain WSGI) to a specific URL prefix. Example::
Method post Equals :meth:`route` with a ``POST`` method parameter.
Method put Equals :meth:`route` with a ``PUT`` method parameter.
Method remove_hook Remove a callback from a hook.
Method reset Reset all routes (force plugins to be re-applied) and clear all caches. If an ID or route object is given, only that specific route is affected.
Method route A decorator to bind a function to a request URL. Example::
Method run Calls :func:`run` with the same parameters.
Method trigger_hook Trigger a hook and return a list of results.
Method uninstall Uninstall plugins. Pass an instance to remove a specific plugin, a type object to remove all plugins that match that type, a string to remove all plugins with a matching ``name`` attribute or ``True`` to remove all plugins...
Method wsgi The bottle WSGI-interface.
Class Variable catchall Undocumented
Instance Variable config Undocumented
Instance Variable error_handler Undocumented
Instance Variable plugins Undocumented
Instance Variable resources Undocumented
Instance Variable router Undocumented
Instance Variable routes Undocumented
Instance Variable stopped Undocumented
Method _cast Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes...
Method _handle Undocumented
Class Variable __hook_names Undocumented
Class Variable __hook_reversed Undocumented
Property _hooks Undocumented
def __call__(self, environ, start_response): (source)

Each instance of :class:'Bottle' is a WSGI application.

def __init__(self, catchall=True, autojson=True): (source)

Undocumented

def add_hook(self, name, func): (source)

Attach a callback to a hook. Three hooks are currently implemented: before_request Executed once before each request. The request context is available, but no routing has happened yet. after_request Executed once after each request regardless of its outcome. app_reset Called whenever :meth:`Bottle.reset` is called.

def add_route(self, route): (source)

Add a route object, but do not change the :data:`Route.app` attribute.

def close(self): (source)

Close the application and all installed plugins.

def default_error_handler(self, res): (source)

Undocumented

def delete(self, path=None, method='DELETE', **options): (source)

Equals :meth:`route` with a ``DELETE`` method parameter.

def error(self, code=500): (source)

Decorator: Register an output handler for a HTTP error code

def get(self, path=None, method='GET', **options): (source)

Equals :meth:`route`.

def get_url(self, routename, **kargs): (source)

Return a string that matches a named route

def hook(self, name): (source)

Return a decorator that attaches a callback to a hook. See :meth:`add_hook` for details.

def install(self, plugin): (source)

Add a plugin to the list of plugins and prepare it for being applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API.

def match(self, environ): (source)

Search for a matching route and return a (:class:`Route` , urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.

def merge(self, routes): (source)

Merge the routes of another :class:`Bottle` application or a list of :class:`Route` objects into this application. The routes keep their 'owner', meaning that the :data:`Route.app` attribute is not changed.

def mount(self, prefix, app, **options): (source)

Mount an application (:class:`Bottle` or plain WSGI) to a specific URL prefix. Example:: root_app.mount('/admin/', admin_app) :param prefix: path prefix or `mount-point`. If it ends in a slash, that slash is mandatory. :param app: an instance of :class:`Bottle` or a WSGI application. All other parameters are passed to the underlying :meth:`route` call.

def post(self, path=None, method='POST', **options): (source)

Equals :meth:`route` with a ``POST`` method parameter.

def put(self, path=None, method='PUT', **options): (source)

Equals :meth:`route` with a ``PUT`` method parameter.

def remove_hook(self, name, func): (source)

Remove a callback from a hook.

def reset(self, route=None): (source)

Reset all routes (force plugins to be re-applied) and clear all caches. If an ID or route object is given, only that specific route is affected.

def route(self, path=None, method='GET', callback=None, name=None, apply=None, skip=None, **config): (source)

A decorator to bind a function to a request URL. Example:: @app.route('/hello/:name') def hello(name): return 'Hello %s' % name The ``:name`` part is a wildcard. See :class:`Router` for syntax details. :param path: Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function. :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. (default: `GET`) :param callback: An optional shortcut to avoid the decorator syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` :param name: The name for this route. (default: None) :param apply: A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins. :param skip: A list of plugins, plugin classes or names. Matching plugins are not installed to this route. ``True`` skips all. Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see :meth:`Plugin.apply`).

def run(self, **kwargs): (source)

Calls :func:`run` with the same parameters.

def trigger_hook(self, __name, *args, **kwargs): (source)

Trigger a hook and return a list of results.

def uninstall(self, plugin): (source)

Uninstall plugins. Pass an instance to remove a specific plugin, a type object to remove all plugins that match that type, a string to remove all plugins with a matching ``name`` attribute or ``True`` to remove all plugins. Return the list of removed plugins.

def wsgi(self, environ, start_response): (source)

The bottle WSGI-interface.

catchall = (source)

Undocumented

Undocumented

error_handler: dict = (source)

Undocumented

Undocumented

resources = (source)

Undocumented

Undocumented

Undocumented

Undocumented

def _cast(self, out, peek=None): (source)

Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes

def _handle(self, environ): (source)

Undocumented

__hook_names: tuple[str, ...] = (source)

Undocumented

__hook_reversed: str = (source)

Undocumented

Undocumented