[英]Python CGI script not executing when run through HTML form
我正在尝试使用python的cgi模块进行试验,广告并不想为了完成此任务而购买整个服务器。 因此,我已在Ubuntu 14.04计算机上编写了html和python cgi脚本,但是该脚本无法运行。 以下是相关的HTML代码:
<form action = "cgi-bin/Login.py" method="get">
Username <input type = "text" name = "user"><br>
Password: <input type = "password" name = "password"><br>
<input type = "submit" value = "Submit"><br>
</form>
还有Python 3代码
import cgi, cgitb
form = cgi.FieldStorage()
# Get data from fields
Username = form.getvalue('user')
Password = form.getvalue('password')
print ("Content-type:text/html")
print ()
print ("<html>")
print ("<head>")
print ("<title>Hello - Second CGI Program</title>")
print ("</head>")
print ("<body>")
print ("<h2>Hello %s %s</h2>" % (Username, Password))
print ("</body>")
print ("</html>")
最后,当我单击网页上的“提交”按钮时出现的弹出窗口。
您需要设置和配置Web服务器以提供cgi脚本。 这是有关此文件的apache文档。
尝试使用POST形式。 python上的CGI需要POST才能起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.