>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 で以下の画面が出る。
超簡単!