Skip to content
Related Articles

Related Articles

How to perform multiplication using CherryPy in Python?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 25 Oct, 2020
View Discussion
Improve Article
Save Article

CherryPy also known as a web application library is a Python web framework that provides a friendly interface to the HTTP protocol for Python developers. It allows developers to build web applications the same way as in traditional object-oriented Python programs. Thereby, resulting in smaller source code developed in no time.

This framework is mainly for the developers who want to create a portable database-driven web application using Python, as it provides Create, Retrieve, Update, and Delete functionalities.

The basic requirements for the installation of CherryPy include:

  • Python with version 2.4 or above
  • Cherrypy 3.0

To install cherrypy run the following command in terminal:

pip install cherrypy


  • Create a user interface to take input from the user.
  • Write cherrypy program to perform required operations

HTML code to create a user interface to take input from the user:


  <div class="container">   
    <form action="store" id="form" method="GET"
    <input type="number" name="number1" /><br /> 
    <input type="number" name="number2" /><br /> 
    <input style="margin-left: 250px;" id=" submit" type="submit"/></div

Cherrypy code for multiplication


import cherrypy
class Root(object):
    def index(self):
        return """<html> 
<div class="container"> 
    <form action="store" id="form" method="GET"> 
    <input type="number" name="num1" /><br /> 
    <input type="number" name="num2" /><br /> 
    <input style="margin-left: 250px;" id=" submit" type="submit"/></div> 
    def store(self, num1, num2):
        mul1 = int(num1)
        mul2 = int(num2)
        result = mul1*mul2
        out = """<html> 
<p> Sum: %s</p>
        <a style="color:red; font-size:35px;" id="shutdown"; href="./shutdown"><i>Shutdown Server</i></a> 
        return out % (result)
    def shutdown(self):
if __name__ == "__main__":
    cherrypy.config.update({'server.socket_port': 8087})


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!