CherryPy – A Minimalist Python Web Framework

 cherrypy_logo_big

CherryPy is an open source, fast, and stable python web framework that allows the developers to build the web applications. The developers can build the web applications as the way they would build the other object-oriented python programs. Many developers still haven’t heard this simple, yet powerful framework, because it is not a complete stack with built-in support for a multi-tier architecture. The developers of CherryPy call it as pythonic framework, because it closely follows the conventions of Python.

Features

  • Simplicity – Developing applications is much easier than anyother frameworks. You don’t have to learn the entire framework to develop a application.
  • Powerful – Hence, it follows the conventions of Python, the CherryPy applications are as like as regular Python applications. You don’t need to learn a new language. If you’re a Python programmer, then CheeryPy is easy to use.
  • Built-in web server – It Includes its own web server to host your application. Also, you can use any other popular web servers like Apache or nginx.
  • It is completely free and open source.

Installation

Make sure you have installed the most recent version of python-pip. If you didn’t install python-pip yet, use the following command.

On Debian based systems:

sudo apt-get install python-pip

On RPM based systems:

yum install python-pip

After installing python-pip, install CherryPy using the following commands with root user privileges:

pip install cherrypy

Or

easy_install cherrypy

You can verify the successful installation of CherryPy using the following command. CherryPy comes with some sample tutorials. So, you can test them as shown below.

python -m cherrypy.tutorial.tut01_helloworld

Sample Output:

[18/Oct/2014:18:09:01] ENGINE Listening for SIGHUP.
[18/Oct/2014:18:09:01] ENGINE Listening for SIGTERM.
[18/Oct/2014:18:09:01] ENGINE Listening for SIGUSR1.
[18/Oct/2014:18:09:01] ENGINE Bus STARTING
[18/Oct/2014:18:09:01] ENGINE Started monitor thread '_TimeoutMonitor'.
[18/Oct/2014:18:09:01] ENGINE Started monitor thread 'Autoreloader'.
[18/Oct/2014:18:09:01] ENGINE Serving on http://127.0.0.1:8080
[18/Oct/2014:18:09:01] ENGINE Bus STARTED

Now, open your web browser, and point it to http://127.0.0.1:8080/.

You’ll see the “Hello world” message in your browser.

As I don’t have GUI mode in my server, I accessed the test page using command “lynx http://127.0.0.1:8080/” from my Terminal.

Sample output:

root@server:~_001

That’s it. CherryPy is working now.

What’s Next? CherryPy community has some cool sample articles here. Go on, learn them, and build your CherryPy applications like a boss.

Cheers!!

Source & Reference Link: