CherryPy is a minimalistic, pythonic and object oriented web framework.
Web Frameworks normally allow developers to develop web applications without getting their hands dirty with low level details such as HTTP protocols and threading concepts.
CherryPy is a battle-tested framework that has existed in the industry for more than a decade.
However, it’s very modern and allows us build applications the way you would build any Object Oriented application in Python.
This makes it very attractive especially for those people coming from system or more general-purpose languages like C++, Java and Python.
The code written in CherryPy is one of the cleanest and attractive you’ll ever see. Python is always a language considered to be for artists due to its beauty, and certainly CherryPy more than fits that profile.
CherryPy is considered minimalistic in that it wraps the HTTP protocol and does not otherwise offer much more than what is defined in the RFC 7231. However, this makes it very extensible and also easy to grasp. Extensible can be done via packages.
We are Building a Vibrant YouTube Community
We have a fast rising YouTube Channel of friends. So far we’ve accumulated almost 3 million agreggate views and more than 10,000 subscribers as of the time of writing this. Here’s the Channel: ProgrammingWizards TV.
Please go ahead subscribe(free obviously) as well. If you have a question or a comment you can post there instead of in this site.People are suggesting us tutorials to do there so you can too.
- CherryPy allows us write web applications in Object Oriented manner.
- CherryPy includes a reliable HTTP/1.1 compliant, WSGI thread-pooled web server. This makes it a viable production ready web server just like it is a web framework.
By being HTTP/1.1 compliant, this makes cherryPy take advantage of latest features HTTP features that allow construction of practical information systems.
HTTP as you know stands for HyperText Transfer Protocol, and is an application-level protocol for distributed, collaborative and hypermedia information systems.
HTTP has been powering the web for almost 3 decades since the inception of World Wide Web by Sir Tim Berners Lee.
- Thirdly CherryPy is easy to run on multiple HTTP servers via different ports at once.
- CherryPy is enhanced with powerful built-in tools for caching, data encoding,sessions, authentication, static content etcetra.
- CherryPy can run on Python 2.7+,3.1+, PyPy, Jython and even Android via the SL4A.
- CherryPy is open source and is distributed under the BSD license.
CherryPy website is here.
Object Relational Mappers
The following are some of the Object Relational Mappers that can be used with CherryPy.
- SQLAchemy – an ORM for python applications.
- SQLObject – an ORM that provides an object interface to a database.
- Storm – the ORM made by Canonical Ltd, who are makers of Ubuntu.
The following are some of the templating languages that can be used with CherryPy:
- Jinja – General purpose tempating language.
- Mako – Template language written in Python.
- Cheetah – Open source template engine.
- CherryTemplate – a templating language for CherryPy.
- Genshi – XML templating language.
Here’s a simple Hello World in CherryPy.
import cherrypy class MrHello(object): def index(self): return "Mr Hello says: `Hello World!`" index.exposed = True cherrypy.quickstart(MrHello())
This will start the CherryPy server at a port probably
ENGINE Serving on http://127.0.0.1:8080
Pount that URL browser and you’ll see a message like this:
Mr Hello says: `Hello World!`