web开发

1. 控制你的代码

Head First Python支持网站http://python.itcarlow.ie/resources.html,下载webapp.zip, 解压到硬盘。

点击以下红下划线链接下载。

 

 

 

 

 

 

 

 

 

 

 

2. CGI让Web服务器运行程序

用python打开simple_htpd.py并Run。结果返回Starting simple_httpd on port: 8080

 

 

 这里的web\simple_htpd.py和lib\simple_htpd.py都可以,我只是把这个.py文件统一整理到了python的lib库中。

 3. 显示选手列表

# Author kevin_hou
import athletemodel
import yate
import glob

deta_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)
print(yate.start_response())
print(yate.include_header("Coach Kelly'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"}))

4. 测试驱动。在浏览器输入http://localhost:8080/即可弹出如下界面。

 

posted @ 2020-09-27 16:24  JRS077  阅读(167)  评论(0编辑  收藏  举报