For faster navigation, this Iframe is preloading the Wikiwand page for CherryPy.

CherryPy

CherryPy
开发者CherryPy team
首次发布2002年6月,​22年前​(2002-06[1]
当前版本
  • 18.8.0 (2022年7月18日;稳定版本)[2]
编辑维基数据链接
原始码库CherryPy Repository
编程语言Python
操作系统跨平台
类型Web应用框架
许可协议BSD许可证[3]
网站cherrypy.org

CherryPy是一个面向对象web应用框架,使用了Python编程语言。它设计用于web应用快速开发,通过包裹HTTP协议,但停留在低层而不提供超出RFC 7231所定义的东西。

CherryPy自身可以是个web伺服器,也可以通过任何WSGI兼容环境来启动它。它不处置用于输出呈现的模板或后端访问的任务。这个框架可以采用过滤器来扩展,它被调用于请求/响应处理的确定点上。

Python化接口

这个项目创立者Remi Delon英语Remi Delon的目标之一,是使得CherryPy尽可能的体现Python原则。这允许开发者将这个框架同任何正规Python模块一样的使用,而忘记(从技术的角度)这个应用是用于web。

例如,常见的Hello World程序用CherryPy 3将写为如下:

import cherrypy

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

cherrypy.quickstart(HelloWorld())

特征

CherryPy实现了:

  • 遵循HTTP/1.1、WSGI线程池的webserver[4]。典型的,CherryPy自身每页只用1–2ms[5][6]
  • 支持任何任何其他启用WSGI的web伺服器或适配器,包括ApacheIISlighttpdmod_python英语mod_pythonFastCGISCGImod_wsgi英语mod_wsgi
  • 一个原生的mod_python英语mod_python适配器。
  • 多个HTTP伺服器(就是有能力监听多个端口)[7]
  • 一个插件系统[8],CherryPy插件挂钩到在伺服器进程内的事件,伺服器启动、伺服器关闭、伺服器退出等,用来执行在伺服器启动和关闭时需要运行的代码。
  • 内建工具用于缓存编码会话授权、静态内容和其他。CherryPy工具挂钩到在请求处理内的事件。在CherryPy伺服器收到一个请求的时候,它有一组特定的步骤要履行来处理这个请求。页面处理器只是这个处理的步骤之一。工具还提供语法和配置API来为特定集合的处理器而打开和关闭它们。
  • 给开发者和部署者的一个配置系统[9][10][11]。CherryPy部署可配置于站点上、应用上和在控制器层面上,通过Python字典、配置文件和打开文件对象。
  • 一个完全的测试包用于核心功能和有关框架,可以用来测试CherryPy应用[12]
  • 内建剖析自从v2.1[13]覆盖[14]和测试支持。

CherryPy不强制使用特定对象关系映射器(ORM)、模板语言英语Web template systemJavaScript库

可用于CherryPy的模块

  • Routes,一个Ruby on Rails的路由系统的Python重新实现,用于映射URL到控制器/行动和生成URL[15]

对象关系映射器

模板语言

参见

引用

  1. ^ History of CherryPy. [2021-03-12]. (原始内容存档于2018-12-15). 
  2. ^ Release v18.8.0. 2022年7月18日 [2022年7月18日]. 
  3. ^ cherrypy / CherryPy / source / cherrypy / LICENSE.txt. BitBucket. [2015-02-21]. (原始内容存档于2017-07-15). 
  4. ^ 存档副本. [2021-03-12]. (原始内容存档于2021-05-14). 
  5. ^ CherryPy v3 WSGI server benchmark results. [2009-09-23]. (原始内容存档于2016-03-03). 
  6. ^ How fast is CherryPy? 互联网档案馆存档,存档日期2010-02-10.
  7. ^ How to set up multiple HTTP servers with CherryPy. [2009-09-23]. (原始内容存档于2016-03-03). 
  8. ^ Custom engine plugins with CherryPy 互联网档案馆存档,存档日期2009-05-03.
  9. ^ Configuration system of CherryPy 互联网档案馆存档,存档日期2009-06-26.
  10. ^ Configuration API of CherryPy 互联网档案馆存档,存档日期2009-07-01.
  11. ^ Short summary of configuration options. [2021-03-12]. (原始内容存档于2010-08-18). 
  12. ^ How to test CherryPy itself 互联网档案馆存档,存档日期2009-09-27.
  13. ^ Profiler module of CherryPy 互联网档案馆存档,存档日期2010-02-09.
  14. ^ How to collect and the analyse coverage data of application code with CherryPy. [2009-09-23]. (原始内容存档于2015-11-17). 
  15. ^ Routes Documentation. [2021-03-13]. (原始内容存档于2019-11-28). 
  16. ^ mongoengine.org. [2021-03-13]. (原始内容存档于2021-01-17). 
  17. ^ Mako Templates for Python. [2021-03-12]. (原始内容存档于2021-05-11). 
  18. ^ A simple CherryPy tool for Mako templating. [2009-09-21]. (原始内容存档于2016-03-03). 
  19. ^ CherryPy – Genshi. [2009-09-26]. (原始内容存档于2012-07-04). 
  20. ^ Genshi - CherryPy Tools - Trac. [2009-09-26]. (原始内容存档于2012-02-27). 
  21. ^ A basic CherryPy Tool for using Jinja templates. [2009-09-23]. (原始内容存档于2015-09-05). 

外部链接

{{bottomLinkPreText}} {{bottomLinkText}}
CherryPy
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?