前言
书中使用的是python3,我这里使用的是python2.7
Web 的目录树
webapp/
├── cgi-bin
│ ├── athletelist.py
│ ├── athletemodel.py
│ ├── generate_list.py
│ └── yate.py
├── coach.css
├── data
│ ├── james.txt
│ ├── julie.txt
│ ├── mikey.txt
│ └── sarah.txt
├── favicon.ico
├── images
│ └── coach-head.jpg
├── index.html
├── simplehttp.py
└── templates
│ ├── footer.html
│ └── header.html
整体的功能
整体的功能是创建一个网站,index.html中有个链接,链接到cgi-bin下的generate_list.py,这个cgi脚本自动生成html代码。
Python启动本地web服务器
由于书中使用的是python3的代码,所以自己在网上找了python2.7的代码
simplehttp.py
1 importBaseHTTPServer, CGIHTTPServer2
3 port = 8080
4
5 httpd = BaseHTTPServer.HTTPServer(('', port), CGIHTTPServer.CG