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 1131 2
Number Guessing Game using Python 768 2
Pyperclip: Not Implemented Error 1546 2
Hangman Game using Python 20008 2
Using Databases with CherryPy application 2273 2
nose: Working 601 2
pytest: Working 600 2
Open Source and Hacktoberfest 981 2
Managing Logs of CherryPy applications 1177 2
Top 20 Data Science Tools 787 2
Ajax application using CherryPy 930 2
REST application using CherryPy 777 2
On Screen Keyboard using Python 8409 2
Elastic Net Regression 1008 2
US Presidential Election 2020 Prediction using Python 877 2
Sound Source Separation 1376 2
URLs with Parameters in CherryPy 2267 2
Testing CherryPy application 766 2
Handling HTML Forms with CherryPy 1908 2
Applications of Natural Language Processing in Businesses 605 2
NetworkX: Multigraphs 876 2
Tracking User Activity with CherryPy 1664 2
CherryPy: Handling Cookies 1201 2
Introduction to NetworkX 715 2
TorchServe - Serving PyTorch Models 1539 2
Fake News Detection Model using Python 839 2
Keeping Home Routers secure while working remotely 567 2
Email Slicer using Python 3167 2
NetworkX: Creating a Graph 1207 2
Best Mathematics Courses for Machine Learning 644 2
Hello World in CherryPy 960 2
Building dependencies as Meson subprojects 1235 2
Vehicle Detection System 1223 2
NetworkX: Examining and Removing Graph Elements 704 2
Handling URLs with CherryPy 626 2
PEP 8 - Guide to Beautiful Python Code 860 2
NetworkX: Drawing Graphs 739 2
Mad Libs Game using Python 757 2
Hosting Cherry applications 715 2
Top 5 Free Online IDEs of 2020 993 2
pytest: Introduction 612 2
Preventing Pwned and Reused Passwords 658 2
Contact Book using Python 2330 2
Introduction to CherryPy 636 2
nose: Introduction 574 2
Text-based Adventure Game using Python 3487 2
NetworkX: Adding Attributes 3242 2
NetworkX: Directed Graphs 1245 2
Dice Simulator using Python 659 2
Decorating CherryPy applications using CSS 1034 2

Comments