手軽なpython3系対応WSGIフレームワーク bottle


>bottleというフレームワークが素晴らしくシンプルだったので、書いてみる。

まずはインストール。

1
pip install bottle

適当なフォルダに以下のファイル作成。
test.py

1
2
3
4
5
6
7
from bottle import route, run
 
@route('/hello/:name')
def index(name='World'):
    return '<b>Hello %s!</b>' % name
 
run(host='localhost', port=8100)

あとは実行するだけ。

1
python test.py

http://localhost:8100/hello/matsu で以下の画面が出る。

超簡単!

コメントする

あなたのメールは 絶対に 公開されたり共有されたりしません。

次の HTML タグと属性が使用できます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>