2017年7月21日金曜日

開発環境

Head First Python (Paul Barry (著)、O'Reilly Media)のChapter 5.(Building a Webapp: Getting Real)の SHARPEN YOUR PENCIL(No. 4140) を取り組んでみる。

SHARPEN YOUR PENCIL(No. 4140)

コード(Emacs)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import Flask
import vsearch

app = Flask(__name__)


@app.route('/')
def hello() -> str:
    return 'Hello world from Flask!'


@app.route('/search4')
def do_search() -> str:
    return str(vsearch.search4letters('life, the universe, and everything'))

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

入出力結果(Terminal, IPython)

$ ./hello_flask.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [21/Jul/2017 18:48:26] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [21/Jul/2017 18:48:26] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [21/Jul/2017 18:48:31] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [21/Jul/2017 18:48:33] "GET /search4 HTTP/1.1" 200 -
127.0.0.1 - - [21/Jul/2017 18:48:34] "GET /search HTTP/1.1" 404 -
127.0.0.1 - - [21/Jul/2017 18:48:34] "GET /search4 HTTP/1.1" 200 -
127.0.0.1 - - [21/Jul/2017 18:48:34] "GET /search4 HTTP/1.1" 200 -
  C-c C-c$

0 コメント:

コメントを投稿