2014年6月25日水曜日

開発環境

Head First Python (Paul Barry(著)、 O'Reilly Media )のChapter 7(Web Development: Putting it all together)、POOL PUZZLE(p.237)を解いてみる。

POOL PUZZLE(p.237)

コード(BBEdit)

/cgi-bin/generate_list.py

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

import athletemodel
import yate
import glob

data_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)

print(yate.start_response())
print(yate.include_header("Coach Key's List of Athletes"))
print(yate.start_form('generate_timing_data.py'))
print(yate.para('Select an athlete from the list to work with:'))
for each_athlete in athletes:
    print(yate.radio_button('which_athlete', athletes[each_athlete].name))
print(yate.end_form('Select'))
print(yate.include_footer({'Home':'/index.html'}))

入出力結果(Terminal)

$ ./simple_httpd.py 
Starting simple_httpd on port: 8080
127.0.0.1 - - [25/Jun/2014 14:17:03] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [25/Jun/2014 14:17:03] "GET /images/coach-head.jpg HTTP/1.1" 200 -
127.0.0.1 - - [25/Jun/2014 14:17:03] "GET /coach.css HTTP/1.1" 200 -
127.0.0.1 - - [25/Jun/2014 14:17:09] "GET /cgi-bin/generate_list.py HTTP/1.1" 200 -
127.0.0.1 - - [25/Jun/2014 14:17:13] code 404, message No such CGI script ('/cgi-bin/generate_timing_data.py')
127.0.0.1 - - [25/Jun/2014 14:17:13] "POST /cgi-bin/generate_timing_data.py HTTP/1.1" 404 -
  C-c C-cTraceback (most recent call last):
  File "./simple_httpd.py", line 10, in <module>
    httpd.serve_forever()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 236, in serve_forever
    poll_interval)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 154, in _eintr_retry
    return func(*args)
KeyboardInterrupt
$

0 コメント:

コメントを投稿