CherryPy——基于Python的Web框架

CherryPy是一个Python HTTP框架,它允许开发者通过Python对象映射URL来构建Web应用。它不提供模板语言,但支持内嵌templating。CherryPy的工作原理包括将URL映射到可调用对象,提供了URI调度机制,如HTTP方法分派、Routes分派和Virtual Host分派。CherryPy可用于构建Web服务,并能与Ajax技术结合。虽然自由度高,但也意味着需要从头开始构建许多功能。
摘要由CSDN通过智能技术生成

CherryPy——基于Python的Web框架

CherryPy是什么(What is CherryPy)

CherryPy是一个基于Python的面向对象的HTTP框架。使用CherryPy来开发Web Application是非常轻松的。但CherryPy并没用提供一种类似于PHP的templating语言机制。

以下的内容摘自CherryPy Tutorial

CherryPy is a pythonic, object-oriented HTTP framework. It provides the foundation over which complex web-based applications can be written, with little or no knowledge of the underlying protocols.

As an HTTP framework, CherryPy does all that is necessary to allow Python code to be executed when some resource (or URL) is requested by the user. However, it is not a templating language, such as PHP.

 

CherryPy的运行机制(How does CherryPy work)

CherryPy将URL映射到Python可调用对象(Python callable)来完成HTTP请求。以下的内容摘自CherryPy Tutorial

Publishing objects
Any object that is attached to the root object is said to be published. This means that the object is accessible via the internal URL-to-object mapping routine. However, it does not mean that the object itself is directly accessible via the Web. For this to happen, the object has to be exposed.
 
Exposing objects
CherryPy maps URL requests to objects and calls the suitable method automatically. The methods that can be called as a result of external requests are said to be exposed.
 
Finding the correct object
For the user, a web application is just like a website with static files. The user types (or clicks) a URL, and gets to the desired webpage. A conventional webserver uses the URL to retrieve a static file from the filesystem. On the other hand, a web application server not only serves the content from static files; it can also map the URL it receives into some object and call it. The result is then sent back to the user's browser, where it is rendered into a viewable page. The result is a dynamic web application; for each URL, a unique object can be called into
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值