Book Image

CherryPy Essentials: Rapid Python Web Application Development

By : Sylvain Hellegouarch
Book Image

CherryPy Essentials: Rapid Python Web Application Development

By: Sylvain Hellegouarch

Overview of this book

<p>CherryPy is a Python library for web development that allows developers to build web applications in the same way as any other object-oriented Python program. Enriched by several years of active development, it has become one of the most established toolkits for building solid and high-performance web applications in Python. CherryPy abstracts the complex low-level HTTP protocol into an easy-to-use interface that respects Python idioms. The library aims at being simple to learn for a beginner while offering the most advanced features to fluent Python developers. For these reasons CherryPy was chosen to be at the heart of the popular and feature-rich TurboGears web framework. CherryPy-powered web applications are stand-alone Python applications with their own embedded multi-threaded web server, but can also run behind Apache or IIS for scalability.</p>
Table of Contents (17 chapters)
CherryPy Essentials
Credits
About the Author
Acknowledgement
About the Reviewers
Preface
Index

Deployment


Deploying a CherryPy-based application can be as easy as dropping the application in an environment, where all the required packages (CherryPy, Kid, simplejson, etc.) are available from the Python system path. However, in a shared web-hosted environment, it is quite likely that the CherryPy web server will reside behind a front-end server such as Apache or lighttpd, allowing the host provider to perform some filtering operations if needed, or for instance let that front end serve the static files in a more efficient fashion than CherryPy.

This section will present a few solutions to run a CherryPy application behind the Apache and lighttpd web servers.

Before explaining how to use CherryPy behind Apache or lighttpd, let's define a simple application that we will use throughout the example:

import.cherrypy
def setup_app():
  class Root:
    @cherrypy.expose
    def index(self):
      # Will return the hostname used by CherryPy and the remote
      # caller IP address
      return...