参考:http://bottlepy.org/docs/dev/bottle-docs.pdf
解压安装:python setup.py install
小试:
# -*- coding: utf-8 -*-
#file : basic.py
from bottle import route, run, template
@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8081)
# -*- coding: utf-8 -*-
#file : basic2.py
from bottle import Bottle, run
app = Bottle()
@app.route("/hello")
def hello():
return "Hello World!"
run(app, host="localhost", port=8081)
dos命令行运行:
python basic1.py
http://localhost:8081/hello/world
python basic2.py
效果分别为: