Hosting Cherry applications














































Hosting Cherry applications



Python: CherryPy

HOSTING CHERRYPY APPLICATIONS

To access applications globally through the internet it is important to host them. For that web applications need an HTTP server. CherryPy provides its own, production ready, HTTP servers. There are two ways to host an application in CherryPy:

Single application

The most straightforward way is to use cherrypy.quickstart() function. It takes three arguments of which two are optional. First, the instance of the application to host. Second, the base path at which the application will be accessible from. Third, a configuration dictionary containing the settings to configure the application.

Eg.:

cherrypy.quickstart(Web()) cherrypy.quickstart(Web(), '/index') cherrypy.quickstart(Web(), '/index', {'/': {'tools.gzip.on': True}})

The first example makes the application available at http://localhost:8080/ whereas the other two will make it available at http://localhost:8080/blog. In addition, the last one provides specific settings for the application.

Multiple applications

The cherrypy.quickstart() does not work for hosting multiple applications. The cherrypy.tree.mount function is used for hosting multiple applications using CherryPy:

Eg.:

cherrypy.tree.mount(Web(), '/web_index', web_conf) cherrypy.tree.mount(App(), '/app_index', app_conf) cherrypy.engine.start() cherrypy.engine.block()

Note that cherrypy.tree.mount() takes the same parameters as cherrypy.quickstart(): an application, a hosting path segment and a configuration dictionary. The last two lines are to start the application servers.


More Articles of Aniket Sharma:

Name Views Likes
Pyperclip: Installation and Working 990 2
Number Guessing Game using Python 683 2
Pyperclip: Not Implemented Error 1026 2
Hangman Game using Python 16785 2
Using Databases with CherryPy application 1672 2
nose: Working 507 2
pytest: Working 511 2
Open Source and Hacktoberfest 867 2
Managing Logs of CherryPy applications 1001 2
Top 20 Data Science Tools 684 2
Ajax application using CherryPy 799 2
REST application using CherryPy 664 2
On Screen Keyboard using Python 5508 2
Elastic Net Regression 815 2
US Presidential Election 2020 Prediction using Python 794 2
Sound Source Separation 1164 2
URLs with Parameters in CherryPy 1633 2
Testing CherryPy application 635 2
Handling HTML Forms with CherryPy 1448 2
Applications of Natural Language Processing in Businesses 509 2
NetworkX: Multigraphs 648 2
Tracking User Activity with CherryPy 1397 2
CherryPy: Handling Cookies 820 2
Introduction to NetworkX 633 2
TorchServe - Serving PyTorch Models 1302 2
Fake News Detection Model using Python 734 2
Keeping Home Routers secure while working remotely 483 2
Email Slicer using Python 2996 2
NetworkX: Creating a Graph 1108 2
Best Mathematics Courses for Machine Learning 551 2
Hello World in CherryPy 680 2
Building dependencies as Meson subprojects 978 2
Vehicle Detection System 1081 2
NetworkX: Examining and Removing Graph Elements 608 2
Handling URLs with CherryPy 536 2
PEP 8 - Guide to Beautiful Python Code 757 2
NetworkX: Drawing Graphs 624 2
Mad Libs Game using Python 643 2
Hosting Cherry applications 613 2
Top 5 Free Online IDEs of 2020 867 2
pytest: Introduction 534 2
Preventing Pwned and Reused Passwords 582 2
Contact Book using Python 2095 2
Introduction to CherryPy 547 2
nose: Introduction 505 2
Text-based Adventure Game using Python 3000 2
NetworkX: Adding Attributes 2279 2
NetworkX: Directed Graphs 1021 2
Dice Simulator using Python 560 2
Decorating CherryPy applications using CSS 833 2

Comments