Bottle是一个用于Python编程语言的WSGI微web框架。它被设计为快速、简单和轻量的,可以容易的和快速的开发web应用[2]。它被作为一个单一文件模块发行,不依赖于其他的Python标准库。同一个模块可运行于Python 2.7和3.x[3]。
它提供了具有URL参数支持的请求分派(路由)、模板、内建web伺服器和对很多第三方WSGI/HTTP伺服器和模板引擎的适配器[4]。
特征
- 单一文件可以运行于Python 2.7和3.x二者。
- 可以运行为独立web伺服器或用在(“挂装”)支持WSGI的任何web伺服器之后。
- 内建了叫做SimpleTemplate引擎的模板引擎。
- 支持JSON客户端数据(对于REST和JavaScript客户端)。
- 对数据库和键/值存储和其他特征的插件[5]。
例子
简单的Hello World!程序:
from bottle import route, run, template
@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
参见
引用
外部链接
Wikiwand in your browser!
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.