【发布时间】:2017-12-30 13:40:15
【问题描述】:
大家好,我在通过我的网站调用 python 脚本时遇到问题,无论是使用 PHP 还是 AJAX
我所有的东西,html、php、css 和 .py 都在同一个文件夹中 /var/www/html/
JS:
document.getElementById('print').onclick = function(){Print()};
function Print() {
var param = 'zya';
$.ajax({
type: 'POST',
url: '../degaps1.py',
data: {param: param},
success: function(response){
output = response;
alert(output);
}
});
Python:
degaps1.py
import cgi
import cgitb; cgitb.enable()
print "Content-Type: text/html"
print ""
arguments = cgi.FieldStorage()
print "test"
当我使用没有“../”的“url”时,它正在打印整个代码,现在我在控制台中收到一条消息... 403 Forbidden。我能做些什么来解决它?提前致谢!
如果我没记错的话,警报中的输出应该是“测试”。
【问题讨论】:
-
您的服务器是否配置为运行 CGI 脚本?默认情况下,请求 Python 文件只会为您获取该文件的内容。见:docs.python.org/2/library/…
标签: javascript php python ajax cgi