Application hosting - single and multiple ⚙️
An HTTP server is required to access a web application. CherryPy includes its own production-ready HTTP server. There are two ways to host an application with it. The simple one and the almost-as-simple one.
🔖Single application

The simplest method is to use the cherrypy.quickstart() function. It requires at least one argument, the application instance to host. Two more options are available. First, specify the base path from which the application will be accessible. Second, you'll need a configuration dictionary or file to configure your application.
cherrypy.quickstart(Home())

You can also try this code with Online Python Compiler
Run Code
The above example indicates that your application will be accessible at http://hostname:port/
cherrypy.quickstart(Home(), '/home')
cherrypy.quickstart(Home(), '/home', {'/': {'tools.gzip.on': True}})

You can also try this code with Online Python Compiler
Run Code
The above two examples indicate that your blog application will be accessible at http://hostname:port/home. Furthermore, the last one provides application-specific settings.
Note
In the last case, notice how the settings are still relative to the application, rather than where it is made available, as indicated by the {'/': ... } rather than a {'/home': ... }
🔖Multiple applications

The cherrypy.quickstart() method works well for a single application but does not support hosting multiple applications on the server. To accomplish this, use the cherrypy.tree.mount function as follows:
cherrypy.tree.mount(Home(), '/home', blog_conf)
cherrypy.tree.mount(Forum(), '/forum', forum_conf)

You can also try this code with Online Python Compiler
Run Code
Cherrypy.tree.mount, in simple terms, accepts the same parameters as cherrypy.quickstart() an application, a hosting path segment,, and a configuration. We can simply start the the application server by following command:
cherrypy.engine.start()
cherrypy.engine.block()

You can also try this code with Online Python Compiler
Run Code
Note:
Cherrypy.quickstart() and cherrypy.tree.mount are not mutually exclusive functions.For example, we can write the above lines as:
cherrypy.tree.mount(Home(), '/home', home_conf)
cherrypy.quickstart(Forum(), '/forum', forum_conf)

You can also try this code with Online Python Compiler
Run Code
Frequently Asked Question❓
What is cherrpy?
CherryPy is a Python web framework that provides a user-friendly interface to the HTTP protocol for Python developers.
How to host single application in CherryPy?
For hosting single application on CherryPy we use cherrypy.quickstart() function.It requires at least one argument, the application instance to host.
Is CherryPy free and open source?
CherryPy is an open-source project, so contributions are welcome. If you're interested, you can fork CherryPy on GitHub and submit a pull request with your changes.
Is CherryPy a web server?
In Brief: CherryPy WSGI Web Server. It is a modular component that can serve any Python WSGI web application.
What exactly is the CherryPy framework?
CherryPy is an object-oriented web application framework that is written in Python. It is intended for the rapid development of web applications by wrapping the HTTP protocol, but it remains at a low level and does not provide much more than RFC 7231 defines.
Conclusion ✉️
In this article, we have extensively discussed Hosting one or more applications in cherryPy in detail. If you would like to learn more, check out our articles on
Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc.
Enroll in our courses and refer to the mock test and problems available.
Take a look at the interview experiences and interview bundle for placement preparations.
Happy Coding!