Python的Web框架 Bottle.py
openkk
12年前
Bottle 是一个快速、简单而且轻量级的 WSGI 微型 web 框架,可使用一个简单的单文件模块分发,无需依赖其他 Python 标准库。
Bottle 包含模块有:
- 路由: Requests to function-call mapping with support for clean and dynamic URLs.
- 模板: Fast and pythonic built-in template engine and support for mako, jinja2 and cheetah templates.
- 工具: Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.
- 服务器: 内建 HTTP 开发服务器,支持 paste, fapws3, bjoern, Google App Engine, cherrypy or any other WSGI capable HTTP server.
示例代码:
from bottle import route, run @route('/hello/:name') def index(name='World'): return '<b>Hello %s!</b>' % name run(host='localhost', port=8080)