Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with url parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies other than the Python Standard Library.
Homepage and documentation: http://bottlepy.org/
Copyright (c) 2016, Marcel Hellkamp. License: MIT (see LICENSE for details)
Class | AppStack |
A stack-like list. Calling it returns the head of the stack. |
Class | BaseRequest |
A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only. |
Class | BaseResponse |
Storage class for a response body as well as headers and cookies. |
Class | BaseTemplate |
Base class and minimal API for template adapters |
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. |
Class | BottleException |
A base class for exceptions used by bottle. |
Class | ConfigDict |
A dict-like configuration storage with additional support for namespaces, validators, meta-data, on_change listeners and more. |
Class | FileUpload |
No class docstring; 1/1 property, 0/4 instance variable, 0/2 class variable, 3/4 methods documented |
Class | FormsDict |
No summary |
Class | HeaderDict |
A case-insensitive version of MultiDict that defaults to replace the old value instead of appending it. |
Class | HTTPError |
Undocumented |
Class | HTTPResponse |
Undocumented |
Class | LocalRequest |
No summary |
Class | LocalResponse |
No summary |
Class | MultiDict |
This dict stores multiple values per key, but behaves exactly like a normal dict in that it returns only the newest value for any given key. There are special methods available to access the full list of values. |
Class | ResourceManager |
This class manages a list of search paths and helps to find and open application-bound resources (files). |
Class | Route |
This class wraps a route callback along with route specific metadata and configuration and applies Plugins on demand. It is also responsible for turing an URL path rule into a regular expression usable by the Router. |
Class | SimpleTemplate |
No class docstring; 0/2 property, 0/4 instance variable, 1/5 method documented |
Class | WSGIHeaderDict |
No summary |
Function | cookie_decode |
Verify and decode an encoded string. Return an object or None. |
Function | cookie_encode |
Encode and sign a pickle-able object. Return a (byte) string |
Function | cookie_is_encoded |
Return True if the argument looks like a encoded cookie. |
Function | debug |
Change the debug level. There is only one debug level supported at the moment. |
Function | load |
Import a module or fetch an object from a module. |
Function | load_app |
Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See load for the target parameter. |
Function | parse_auth |
Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None |
Function | parse_date |
Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. |
Function | path_shift |
Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. |
Function | run |
Start a server instance. This method blocks until the server terminates. |
Function | template |
No summary |
Function | view |
Decorator: renders a template for a handler. The handler can control its behavior like that: |
Function | yieldroutes |
Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example: |
Constant | DEBUG |
Undocumented |
Constant | ERROR_PAGE_TEMPLATE |
Undocumented |
Constant | NORUN |
Undocumented |
Constant | TEMPLATE_PATH |
Undocumented |
Constant | TEMPLATES |
Undocumented |
Variable | __author__ |
Undocumented |
Variable | __license__ |
Undocumented |
Variable | __version__ |
Undocumented |
Variable | app |
Undocumented |
Variable | callable |
Undocumented |
Variable | cheetah_template |
Undocumented |
Variable | cheetah_view |
Undocumented |
Variable | default_app |
Undocumented |
Variable | delete |
Undocumented |
Variable | error |
Undocumented |
Variable | ext |
Undocumented |
Variable | get |
Undocumented |
Variable | hook |
Undocumented |
Variable | install |
Undocumented |
Variable | jinja2_template |
Undocumented |
Variable | jinja2_view |
Undocumented |
Variable | json_loads |
Undocumented |
Variable | local |
Undocumented |
Variable | mako_template |
Undocumented |
Variable | mako_view |
Undocumented |
Variable | mount |
Undocumented |
Variable | post |
Undocumented |
Variable | put |
Undocumented |
Variable | py25 |
Undocumented |
Variable | py31 |
Undocumented |
Variable | py3k |
Undocumented |
Variable | request |
Undocumented |
Variable | response |
Undocumented |
Variable | route |
Undocumented |
Variable | server_names |
Undocumented |
Variable | tonat |
Undocumented |
Variable | uninstall |
Undocumented |
Variable | url |
Undocumented |
Variable | urlunquote |
Undocumented |
Class | _closeiter |
This only exists to be able to attach a .close method to iterators that do not support attribute assignment (most of itertools). |
Class | _ImportRedirect |
No class docstring; 0/3 instance variable, 1/3 method documented |
Class | AppEngineServer |
Adapter for Google App Engine. |
Class | AutoServer |
Untested. |
Class | BjoernServer |
Fast server written in C: https://github.com/jonashaag/bjoern |
Class | cached_property |
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. |
Class | CGIServer |
Undocumented |
Class | CheetahTemplate |
Undocumented |
Class | CherryPyServer |
Undocumented |
Class | DictProperty |
Property that maps to a key in a local dict-like attribute. |
Class | DieselServer |
Untested. |
Class | EventletServer |
Untested |
Class | FapwsServer |
Extremely fast webserver using libev. See http://www.fapws.org/ |
Class | FileCheckerThread |
Interrupt main-thread as soon as a changed module file is detected, the lockfile gets deleted or gets to old. |
Class | FlupFCGIServer |
Undocumented |
Class | GeventServer |
Untested. Options: |
Class | GeventSocketIOServer |
Undocumented |
Class | GunicornServer |
Untested. See http://gunicorn.org/configure.html for options. |
Class | HeaderProperty |
Undocumented |
Class | Jinja2Template |
Undocumented |
Class | JSONPlugin |
Undocumented |
Class | lazy_attribute |
A property that caches itself to the class object. |
Class | MakoTemplate |
Undocumented |
Class | MeinheldServer |
Undocumented |
Class | NCTextIOWrapper |
Undocumented |
Class | PasteServer |
Undocumented |
Class | PluginError |
Undocumented |
Class | RocketServer |
Untested. |
Class | RouteBuildError |
The route could not be built. |
Class | RouteError |
This is a base class for all routing related exceptions |
Class | Router |
No summary |
Class | RouteReset |
If raised by a plugin or request handler, the route is reset and all plugins are re-applied. |
Class | RouterUnknownModeError |
Undocumented |
Class | RouteSyntaxError |
The route parser found something not supported by this router. |
Class | ServerAdapter |
Undocumented |
Class | StplParser |
Parser for stpl templates. |
Class | StplSyntaxError |
Undocumented |
Class | TemplateError |
Undocumented |
Class | TemplatePlugin |
No summary |
Class | TornadoServer |
The super hyped asynchronous server by facebook. Untested. |
Class | TwistedServer |
Untested. |
Class | WaitressServer |
Undocumented |
Class | WSGIFileWrapper |
Undocumented |
Class | WSGIRefServer |
Undocumented |
Function | _e |
Undocumented |
Function | _file_iter_range |
Yield chunks from a range in a file. No chunk is bigger than maxread. |
Function | _hkey |
Undocumented |
Function | _hval |
Undocumented |
Function | _lscmp |
Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix. |
Function | _parse_qsl |
Undocumented |
Function | _raise |
Undocumented |
Function | _re_flatten |
Turn all capturing groups in a regular expression pattern into non-capturing groups. |
Function | abort |
Aborts execution and causes a HTTP error. |
Function | auth_basic |
Callback decorator to require HTTP auth (basic). TODO: Add route(check_auth=...) parameter. |
Function | depr |
Undocumented |
Function | html_escape |
Escape HTML special characters &<> and quotes '". |
Function | html_quote |
Escape and quote a string to be used as an HTTP attribute. |
Function | http_date |
Undocumented |
Function | json_dumps |
Undocumented |
Function | local_property |
Undocumented |
Function | make_default_app_wrapper |
Return a callable that relays calls to the current default app. |
Function | makelist |
Undocumented |
Function | parse_range_header |
Yield (start, end) ranges parsed from a HTTP Range header. Skip unsatisfiable ranges. The end index is non-inclusive. |
Function | redirect |
Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version. |
Function | static_file |
No summary |
Function | tob |
Undocumented |
Function | touni |
Undocumented |
Function | update_wrapper |
Undocumented |
Constant | _HTTP_STATUS_LINES |
Undocumented |
Variable | _stderr |
Undocumented |
Variable | _stdout |
Undocumented |
Import a module or fetch an object from a module.
module
as a module object.name
from pack.mod
.pack.mod.func()
and returns the result.The last form accepts not only function calls, but any type of expression. Keyword arguments passed to this function are available as local variables. Example: import_string('re:compile(x)', x='[a-z]')
load
for the target parameter.Parameters | |
script_name | The PATH_INFO path. |
path_info | Undocumented |
shift | The number of path fragments to shift. May be negative to change the shift direction. (default: 1) |
Returns | |
The modified paths. |
Parameters | |
app | WSGI application or target string supported by
load_app . (default: default_app ) |
server | Server adapter to use. See server_names keys
for valid names or pass a ServerAdapter subclass.
(default: wsgiref ) |
host | Server address to bind to. Pass 0.0.0.0 to listens on all interfaces including the external one. (default: 127.0.0.1) |
port | Server port to bind to. Values below 1024 require root privileges. (default: 8080) |
interval | Auto-reloader interval in seconds (default: 1) |
reloader | Start auto-reloading server? (default: False) |
quiet | Suppress output to stdout and stderr? (default: False) |
plugins | Undocumented |
debug | Undocumented |
**kargs | Undocumented |
options | Options passed to the server adapter. |
Decorator: renders a template for a handler. The handler can control its behavior like that:
- return a dict of template vars to fill out the template
- return something other than a dict and the view decorator will not process the template, but return the handler result as is. This includes returning a HTTPResponse(dict) to get, for instance, JSON with autojson or other castfilters.
Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example:
a() -> '/a' b(x, y) -> '/b/<x>/<y>' c(x, y=5) -> '/c/<x>' and '/c/<x>/<y>' d(x=5, y=6) -> '/d' and '/d/<x>' and '/d/<x>/<y>'
Undocumented
Value |
|
HTTPResponse
with status
code 200, 305, 403 or 404. The Content-Type, Content-Encoding,
Content-Length and Last-Modified headers are set if possible.
Special support for If-Modified-Since, Range and HEAD
requests.Parameters | |
filename | Name or path of the file to send. |
root | Root path for file lookups. Should be an absolute directory path. |
mimetype | Defines the content-type header (default: guess from file extension) |
download | If True, ask the browser to open a Save as... dialog
instead of opening the file with the associated program. You can
specify a custom filename as a string. If not specified, the
original filename is used (default: False). |
charset | The charset to use for files with a text/* mime-type. (default: UTF-8) |