我有两份档案,索引.html以及表格.py在Windows 10的C:\Apache24\htdocs目录中。内容如下:
你知道吗索引.html你知道吗
<html>
<head>
<title>demo web file python2.7</title>
</head>
<body>
<form name="pyform" method="POST" action="/form.py">
<input type="text" name="fname" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
你知道吗表格.py你知道吗
#!C:\Python27/python
print "Content-Type: text/html"
import cgi,cgitb
cgitb.enable() #for debugging
form = cgi.FieldStorage()
name = form.getvalue('fname')
print "Name of the user is:",name
Apache服务器配置为使用以下设置运行cgi脚本:
DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
Options Indexes FollowSymlinks ExecCGI
AllowOverride All
Require all granted
</Directory>
以及
AddHandler cgi-script .cgi .py
当我填充文本区域并单击页面上的“Submit”按钮时,我在生成的页面上得到python文件的全部内容,而不是我放入框中的内容。你知道吗
缺了什么或者我做错了什么?非常感谢。你知道吗
您需要使用
ScriptAlias
指令将htdocs
标记为CGI程序的备用。你知道吗参考文献:
相关问题 更多 >
编程相关推荐