cgi-server:自动执行/index.sh?

时间:2017-02-05 16:02:41

标签: python python-2.7 python-2.6

这是我的Python脚本,用于侦听端口80并像文件服务器一样将文件夹提供给端口80:

#!/usr/bin/env python  
import BaseHTTPServer  
import CGIHTTPServer  
import cgitb; cgitb.enable()  ## This line enables CGI error reporting  
server = BaseHTTPServer.HTTPServer  
handler = CGIHTTPServer.CGIHTTPRequestHandler  
server_address = ("", 80)  
handler.cgi_directories = ["/"]  

httpd = server(server_address, handler)  
httpd.serve_forever()  

它工作正常,但我希望它能自动执行

  index.sh

如果没有指定文件。这是我的index.sh

#!/bin/sh

echo "Content-type: text/html"
echo ""

echo "this is index page"

换句话说,如果网址为url/,则应将其视为url/index.sh

0 个答案:

没有答案