python CGI编程Apache配置
1. 编辑http.conf,添加两行,路径可以自定义
<Directory "C:/AppServ/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
AddHandler cgi-script .py
AddHandler default-handler .html .htm .css .js
</Directory>
2. 重启apache
3. 编辑测试文件 C:/AppServ/www/cgi-bin/hello.py
#!C:\\Python27\python.exe
#-*-coding:utf-8-*-
import cgi
print "Content-type:text/html\n"
print "<html>"
print "<p>hello world</p>"
print "</html>"
4. 浏览器访问测试
localhost/cgi-bin/hello.py