Cherrypy
CherryPy 是Python面向对象的HTTP框架。使用CherryPy,开发者可以像创建任何其他面向对象Python程序一样建立web应用。这意味着花更少的时间,写更少的代码。CherryPy已经有6年的历史,运行快速稳定,许多网站在产品中使用CherryPy,包括那些很简单和非常复杂的应用。
CherryPy使用非常简单,下载并安装,CherryPy作为Python的一个模块被安装到python目录中,然后就可以像写普通Python程序一样写web程序:
#file: hello.py
import cherrypy
class Content:
@cherrypy.expose
def index(self):
return "hello"
@cherrypy.expose
def gree(self, name=None):
return "Hello " + name
cherrypy.quickstart(Content())
在命令行输入 python hello.py, web程序就运行起来了。在浏览器输入http://localhost:8080 ,将会显示返回的内容,也可以在URL中加入参数 http://localhost:8080?name=james ,在程序中可以很方便的获得传入的参数。简单吧。