Remi Delon created CherryPy in 2002, and it is one of the oldest Python web-framework. Like Flask, it is also a lightweighted Python framework with few dependencies.
What is CherryPy Python Framework?
CherryPy follows the pythonic way, and with its Object Orientation approach, it made it easy for developers to write and wrap web logic around HTTP protocols. Simplicity is the main asset of CherryPy, and it can use Object Relational Mapper (ORM) and templating language extensions for databases and templates.
Features of CherryPy Framework
Although CherryPy is not the most popular Python web framework , you should still know its features before learning it.
- It is one of the simplest Python web frameworks.
- It follows a modular approach to writing web app logic.
- It comes with common web-app building tools like caching, encoding, session, authorizations, static content, and many more.
- It also provides a built-in test suite for rapid internal testing of web applications.
- It can support multiple Object Relational Mappers (ORM) for Data Bases access.
- It can also work with different templating languages such as Mako, Jinja, Genshi, CherryTemplate, etc.
- It is also known as an Object-Oriented web application framework and supports all of its properties like Data hiding and security.
- It is an open-source project and has 1.4K stars on its Github repo.
- It comes with a built-in production-ready HTTP server for development and deployment.
- As it follows Object Orientation concepts, we can use Inheritance in CherryPy for Data Reusability.
Get Started with CherryPy Python
It is a Python web framework, so it goes without saying Python should be installed on your system before you want to create or run a web Application using CherryPy. CherryPy is a third-party open-source library, and we need to install it before wring or running its application. To install CherryPy for our Python environment, we can use the pip install terminal command.
pip install cherrypy
Now let’s write our first CherryPy web application as app.py #app.py
import cherrypy
class HomePage(object):
@cherrypy.expose
def index(self):
return "<h1>Hello World! Welcome To cherryPy</h1>"
if __name__=="__main__":
cherrypy.quickstart(HomePage(),'/')
Now run the app.py as a Python script on your terminal or command prompt.
C:\Users\ code>python app.py
[02/May/2021:12:09:25] ENGINE Listening for SIGTERM.
[02/May/2021:12:09:25] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[02/May/2021:12:09:25] ENGINE Set handler for console events.
[02/May/2021:12:09:25] ENGINE Started monitor thread 'Autoreloader'.
[02/May/2021:12:09:25] ENGINE Serving on http://127.0.0.1:8080
[02/May/2021:12:09:25] ENGINE Bus STARTED
When you run the Python script, it will activate a local server, and you can visit http://127.0.0.1:8080 on your browser to see the output.
Conclusion
CherryPy is a minimal Python web framework. It is designed to follow the Pythonic simpler and modular way of designing web applications. However, it is not the most popular Python web framework, it is still one of the best alternatives for Flask. We can build simple Create, Update, Retrieve, and Delete (CURD) web applications with ease with our minimal approach.
People are also reading:
- HOG Feature Extraction in Python
- Install Python Package Using Jupyter Notebook
- Extract all Stored Chrome Password with Python
- Python readline() Method with Examples
- Automate Login in Python
- Python Coding on a Macbook
- Python Counter in Collections with Examples
- CSV Modules and Pandas in Python
- Python COPY File and Directory
- Python map() Function with Examples
Leave a Comment on this Post