2018年12月8日土曜日

開発環境

入門 Python 3 (Bill Lubanovic (著)、斎藤 康毅 (監修)、長尾 高弘 (翻訳)、オライリージャパン)の9章(ウェブを解きほぐす)、9.4(復習問題)9-5、6.を取り組んでみる。

コード(Emacs)

Python 3

from flask import Flask, render_template, request

app = Flask(__name__)


@app.route('/')
def home():
    thing = request.args.get('thing')
    height = request.args.get('height')
    color = request.args.get('color')
    return render_template('home.html',
                           thing=thing,
                           height=height,
                           color=color)


if __name__ == '__main__':
    app.run(debug=True)

入出力結果(Terminal, cmd(コマンドプロンプト), Jupyter(IPython))

$ python3 sample5.py
 * Serving Flask app "sample5" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 178-619-558
127.0.0.1 - - [08/Dec/2018 18:10:10] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [08/Dec/2018 18:10:10] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [08/Dec/2018 18:10:34] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [08/Dec/2018 18:10:42] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [08/Dec/2018 18:11:06] "GET /?thing=Thing&height=Height&color=Color HTTP/1.1" 200 -
127.0.0.1 - - [08/Dec/2018 18:11:06] "GET /favicon.ico HTTP/1.1" 404 -
  C-c C-c$ ls -R
./  sample5.py static/
../  sample5.py~ templates/

./static:
./ ../

./templates:
./  ../  home.html home.html~
$

0 コメント:

コメントを投稿