📜  CherryPy-词汇

📅  最后修改于: 2020-10-26 05:20:55             🧑  作者: Mango


为了了解CherryPy的工作,需要定义一些重要的关键字。关键字和定义如下-

S.No Keyword & Definition
1.

Web Server

It is an interface dealing with the HTTP protocol. Its goal is to transform the HTTP requests to the application server so that they get the responses.

2.

Application

It is a piece of software which gathers information.

3.

Application server

It is the component holding one or more applications

4.

Web application server

It is the combination of web server and application server.

以下示例显示CherryPy的示例代码-

import cherrypy

class demoExample:
   def index(self):
   return "Hello World!!!"
   index.exposed = True
cherrypy.quickstart(demoExample())

现在让我们了解代码的工作原理-

  • 始终在指定的类中导入名为CherryPy的包,以确保其正常运行。

  • 在上面的示例中,名为index的函数返回参数“ Hello World !!!”。

  • 最后一行启动Web服务器并调用指定的类(此处为demoExample),并返回默认函数索引中提到的值。

示例代码返回以下输出-

示范范例