python web框架之 bottle

参考:http://bottlepy.org/docs/dev/bottle-docs.pdf

下载:https://pypi.python.org/packages/source/b/bottle/bottle-0.11.6.tar.gz#md5=0bafdc4e13ea2b1a3bddf36b5af108c4

解压安装: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

http://localhost:8081/hello 

效果分别为:

python web框架之 bottle


你可能感兴趣的:(python web框架之 bottle)