CherryPy

CherryPy
DeveloperCherryPy team
ReleaseJune 2002; 24 years ago (2002-06)
Stable release
18.10.0 Edit this on Wikidata / 15 June 2024; 2 years ago (15 June 2024)
Written inPython
Operating systemCross-platform
TypeWeb application framework
LicenseBSD License
Websitecherrypy.dev
RepositoryCherryPy Repository

CherryPy is an object-oriented web application framework using the Python programming language. It is designed for rapid development of web applications by wrapping the HTTP protocol but stays at a low level and does not offer much more than what is defined in RFC 7231.

CherryPy can be a web server itself or one can launch it via any WSGI compatible environment. It does not deal with tasks such as templating for output rendering or backend access. The framework is extensible with filters, which are called at defined points in the request/response processing.

Pythonic interface

One of the goals of the project founder, Remi Delon, was to make CherryPy as pythonic as possible. This allows the developer to use the framework as any regular Python module and to forget (from a technical point of view) that the application is for the web.

For instance, the common Hello World program with CherryPy 3 would look like:

import cherrypy

class HelloWorld:
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Or, as the example currently shows on their website, using Python decorators to automatically expose the index route:

import cherrypy

class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello World!"

cherrypy.quickstart(HelloWorld())

Features

CherryPy implements:

CherryPy doesn't force you to use a specific object–relational mapper (ORM), template language or JavaScript library.

Can be used with CherryPy

  • Routes — a Python re-implementation of the Ruby on Rails's routes system for mapping URLs to controllers/actions and generating URLs.

Object–relational mappers

Templating languages

  • Mako — a template library written in Python, usable with a simple CherryPy tool.
  • Cheetah — an open source template engine and code generation tool, written in Python.
  • CherryTemplate — a templating language for CherryPy.
  • Genshi — a powerful XML templating language.
  • Jinja — a general purpose templating language. CherryPy has a tool for using Jinja templates.
  • Kid — a simple template language for XML based vocabularies written in Python. TurboGears 1.x uses CherryPy as server and Kid as frontend.

CherryPy wiki helps choosing a templating language.

Products using CherryPy

  • TurboGears — CherryPy 2.x is a main component of TurboGears 1.x.
  • Splunk Enterprise — CherryPy 3.1.2

See also