Bottle: Python Web Framework¶

Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.

  • Routing: Requests to function-call mapping with support for clean and dynamic URLs.
  • Templates: Fast and pythonic built-in template engine and support for mako, jinja2 and cheetah templates.
  • Utilities: Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.
  • Server: Built-in HTTP development server and support for paste, fapws3, bjoern, Google App Engine, cherrypy or any other WSGI capable HTTP server.

Example: “Hello World” in a bottle

from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)

Run this script or paste it into a Python console, then point your browser to localhost:8080/hello/world. That’s it.

Download and Install

Install the latest stable release via PyPI (easy_install -U bottle) or download bottle.py (unstable) into your project directory. There are no hard [1] dependencies other than the Python standard library. Bottle runs with Python 2.5+ and 3.x.

User’s Guide¶

Start here if you want to learn how to use the bottle framework for web development. If you have any questions not answered here, feel free to ask the mailing list.

  • Tutorial
    • Installation
    • Quickstart: “Hello World”
    • Request Routing
    • Generating content
    • Request Data
    • Templates
    • Plugins
    • Development
    • Deployment
    • Glossary
  • Configuration (DRAFT)
    • Configuration Basics
    • Naming Convention
    • Loading Configuration from a File
    • Loading Configuration from a nested dict
    • Listening to configuration changes
    • Filters and other Meta Data
    • API Documentation
  • Request Routing
    • Rule Syntax
    • Wildcard Filters
    • Legacy Syntax
    • Explicit routing configuration
  • SimpleTemplate Engine
    • SimpleTemplate Syntax
    • Template Functions
    • SimpleTemplate API
  • API Reference
    • Module Contents
    • The Bottle Class
    • The Request Object
    • The Response Object
    • Templates
  • List of available Plugins

Knowledge Base¶

A collection of articles, guides and HOWTOs.

  • Tutorial: Todo-List Application
    • Goals
    • Before We Start...
    • Using Bottle for a Web-Based ToDo List
    • Server Setup
    • Final Words
    • Complete Example Listing
  • Primer to Asynchronous Applications
    • The Limits of Synchronous WSGI
    • Greenlets to the rescue
    • Event Callbacks
    • Finally: WebSockets
  • Recipes
    • Keeping track of Sessions
    • Debugging with Style: Debugging Middleware
    • Unit-Testing Bottle Applications
    • Functional Testing Bottle Applications
    • Embedding other WSGI Apps
    • Ignore trailing slashes
    • Keep-alive requests
    • Gzip Compression in Bottle
    • Using the hooks plugin
    • Using Bottle with Heroku
  • Frequently Asked Questions
    • About Bottle
    • Common Problems and Pitfalls

Development and Contribution¶

These chapters are intended for developers interested in the bottle development and release workflow.

  • Release Notes and Changelog
    • Release 0.12
    • Release 0.11
    • Release 0.10
    • Release 0.9
    • Release 0.8
  • Contributors
  • Developer Notes
    • Get involved
    • Get the Sources
    • Releases and Updates
    • Repository Structure
    • Submitting Patches
    • Building the Documentation
    • GIT Workflow Examples
  • Plugin Development Guide
    • How Plugins Work: The Basics
    • Plugin API
    • The Route Context
    • Runtime optimizations
    • Plugin Example: SQLitePlugin

License¶

Code and documentation are available according to the MIT License:

Copyright (c) 2012, Marcel Hellkamp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

The Bottle logo however is NOT covered by that license. It is allowed to use the logo as a link to the bottle homepage or in direct context with the unmodified library. In all other cases please ask first.

Footnotes

[1]Usage of the template or server adapter classes of course requires the corresponding template or server modules.

spacer

Bottle is a fast, simple and lightweight WSGI micro web-framework for Python.

Installation

Install Bottle with pip install bottle or download the source package at PyPI.

Releases

  • Bottle dev (development)
  • Bottle 0.12 (stable)
  • Bottle 0.11 (old stable)

Download Docs

Download this documentation as PDF or HTML (zip) for offline use.

Resources

  • Twitter news
  • Development blog
  • GitHub repository
  • Mailing list archive
  • Freenode chat

Like it?

  • spacer spacer

Hosted by:

spacer
© Copyright 2009-2015, Marcel Hellkamp - Contact
Last updated on Jan 18, 2015. Created using Sphinx 1.2.1.
Powered by Bottle 0.12
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.