開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 8(The Web, Untangled)、Things to Do 9.4.を解いてみる。
Things to Do 9.4.
コード(Eacs, BBEdit)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import flask
app = flask.Flask(__name__)
@app.route('/')
def echo():
thing = flask.request.args.get('thing')
height = flask.request.args.get('height')
color = flask.request.args.get('color')
return flask.render_template('home.html', thing=thing, height=height,
color=color)
app.run(port=5000, debug=True)
入出力結果(Terminal, IPython)
$ ./sample4.py * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat 127.0.0.1 - - [14/Mar/2015 13:54:42] "GET /?thing=Thing&height=100&color=Red HTTP/1.1" 200 - C-c C-c $
0 コメント:
コメントを投稿