无法在Web服务器上执行Python脚本

时间:2018-06-09 00:22:18

标签: python webserver cgi

我的网站的/test文件夹中包含以下HTML文件:

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Enter the texts to be compared</h1>
    <form action="/cgi-bin/test_python.cgi" method="POST">
    <input type="text" name="text1">
    <input type="text" name="text2">
    <input type="submit" name="my-form" value="Check !">
    </form>
</body>
</html>

我的Python脚本位于我网站的/cgi-bin文件夹中:

#!/usr/bin/python   
print('Content-type: text/html\r\n\r')

我可以使用网络浏览器访问HTML文件,但是按下&#34; Check!&#34;按钮会生成404消息。 CGI文件分配了755个执行权限。

这是共享托管,因此我不确定安装了哪些功能。但CGI至少应该起作用。我是Python的新手。有没有办法让这个设置工作?感谢。

1 个答案:

答案 0 :(得分:1)

检查cgi文件夹本身(不是谈论python cgi文件)也有755权限。我认为这是问题所在。

另外,尝试运行perl cgi示例Hello World文件: https://practicalperl5.blogspot.com/2014/02/hello-world.html