CherryPy is a web framework of Python which provides a friendly interface to the HTTP protocol for Python developers. It is also called a web application library. It allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.
This framework is mainly for the developers who want to create a portable database-driven web applications using Python, as it provides Create, Retrieve, Update and Delete functionalities.
The basic requirements for installation of CherryPy framework include ?
- Python with version 2.4 or above
- CherryPy 3.0
To install cherrypy run the following command in terminal:
pip install cherrypy
A simple Application –
A cherrypy Application typically looks like this:
return “Hello World!”
Project to Upload file and read its content –
Steps taken to upload a file and read its content using cherrypy:
- Create any text file to read or existing file can also be used. Geeks.txt file is used in the program.
- Create user interface that upload a file from system
- Write cherrypy program that read the content of file and show its content.
To stop the engine, use the following code:
Output(Before file upload):
Output(After uploading the file):
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.