我刚刚在Python中制作了一个服务器(仅用于localhost),以便由CGI执行并尝试我的Python脚本。这是文件的执行服务器上的代码:如何在CGI服务器中配置索引文件?
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import BaseHTTPServer
import CGIHTTPServer
import cgitb
cgitb.enable() ## This line enables CGI error reporting
server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_address = ("", 8000)
handler.cgi_directories = ["/"]
httpd = server(server_address, handler)
httpd.serve_forever()
当我在服务器访问某些脚本(http://127.0.0.1:8000/index.py
)是没有问题的,但是当我访问服务器(http://127.0.0.1:8000/
)它表明:
Error response
Error code 403.
Message: CGI script is not executable ('//').
Error code explanation: 403 = Request forbidden -- authorization will not help.
这就像如果索引文件没有被设置为默认的文件访问文件夹,而不是特定的文件的时候访问...
我希望能够在我访问http://127.0.0.1/
来访问http://127.0.0.1/index.py
。谢谢你的一切。