最近在跟着《Head Frist Python》学习,学到网络服务器功能时,用点小项目练手。但是出现了下面的问题:
127.0.0.1 - - [24/Apr/2016 20:51:36] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:51:36] "GET /images/IMG_6582.JPG HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:51:38] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:51:38] "GET /images/IMG_6582.JPG HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:56:12] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:56:12] "GET /images/IMG_6582.JPG HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:56:13] "POST /cgi-bin/original.html HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2016 20:56:13] command: D:\Python学习\深入浅出Python\webapp\cgi-bin\original.html ""
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59900)
代码是:
print('<meta http-equiv=refresh content="10;url=original.html">')
就这一行
command这一段相当于:“用POST指定的程序进行执行”,但是我想要的是GET这个文件。
我用的服务器程序就是书上的例子
from http.server import HTTPServer,CGIHTTPRequestHandler
port = 8080
httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()
刚开始localhost:8080打开index.html的时候背景图片都能成功GET到。