python web框架之 bottle

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

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

解壓安裝:python  setup.py installspa

小試:命令行

# -*- 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命令行運行:code

python basic1.py md5

http://localhost:8081/hello/world  utf-8

python basic2.py
get

http://localhost:8081/hello class

效果分別爲:pdf

相關文章
相關標籤/搜索