Quixote (web框架)
Quixote是一个使用Python开发web应用的软件框架。Quixote是“基于了简单的、灵活的设计,使得可以快速的书写应用,并受益于广泛的可获得的第三方Python模块。”[5]
開發者 | Andrew Kuchling, Neil Schemenauer 和 Greg Ward |
---|---|
首次发布 | 2000年8月12日[1][2] |
当前版本 |
|
源代码库 | |
编程语言 | Python |
操作系统 | 跨平台 |
类型 | Web应用框架 |
许可协议 | MIT许可证 |
网站 | quixote |
Quixote应用典型的是个Python包,即组织入一个单一的目录树中的一组模块。Quixote接着映射一个URL至这个Python包内的一个函数或方法;接着用这个HTTP请求的内容来调用这个函数,并将结果返回给客户端。
演示代码
最小的Quixote演示程序。在安装了quixote包之后,可以如下这样运行它:$ python demo/mini_demo.py
。这个服务器缺省的监听localhost:8080
。调试和错误输出会发送到终端。
from quixote.publish import Publisherfrom quixote.directory import Directory, exportclass RootDirectory(Directory): @export(name='') def index(self): return '''<html> <body>Welcome to the Quixote demo. Here is a <a href="hello">link</a>. </body> </html> ''' @export def hello(self): return '<html><body>Hello world!</body></html>'def create_publisher(): return Publisher(RootDirectory(), display_exceptions='plain')if __name__ == '__main__': from quixote.server.simple_server import run print('creating demo listening on http://localhost:8080/') run(create_publisher, host='localhost', port=8080)