使用 python 处理提交的表单 3
Handling submitted forms with python 3
我正在尝试快速编写 HTML 表格:
<!DOCTYPE html>
<html>
<head>
<title>some title</title>
</head>
<body>
<form method="post" action="filename.cgi">
Deploy Process Name:<br>
<input type="text" name="deploy_process_name"><br>
<input type="submit" name="submitXML" value="Submit XML"/>
</form>
</body>
</html>
我在 python 中使用 cgi 包编写了以下脚本以从表单中提取数据并进行处理:
例如 - 获取 deploy_process_name
import cgi
def htmlTop():
print("""Content-type:text/html\n\n
<!DOCTYPE html>
<html lange="en">
<head>
<title>Title</title>
</head>
<body>""")
def htmlTail():
print("""</body>
</html>""")
def getData():
formData = cgi.FieldStorage()
deploy_pro_name= formData.getvalue("deploy_process_name")
return deploy_pro_name
if __name__ == '__main__':
try:
htmlTop()
depl= getData()
print("DeployProcessName= {}".format(depl))
htmlTail()
except:
cgi.print_exception()
当我点击提交时,它只下载 filename.cgi。
我如何在点击提交后使其成为 运行 以下脚本?
看来你服务器端设置有误。
请严格按照服务器端 CGI 提供的任何内容(无论是 apache httpd、nginx、lighttpd 还是其他)
关注点:
- 脚本文件夹的所有权(用户:组)
- 脚本文件夹的权限
- 脚本的所有权(用户:组)
- 脚本权限
您似乎使用了默认扩展,但您是否确保已加载 CGI 模块并使用该扩展来处理 CGI?
我正在尝试快速编写 HTML 表格:
<!DOCTYPE html>
<html>
<head>
<title>some title</title>
</head>
<body>
<form method="post" action="filename.cgi">
Deploy Process Name:<br>
<input type="text" name="deploy_process_name"><br>
<input type="submit" name="submitXML" value="Submit XML"/>
</form>
</body>
</html>
我在 python 中使用 cgi 包编写了以下脚本以从表单中提取数据并进行处理: 例如 - 获取 deploy_process_name
import cgi
def htmlTop():
print("""Content-type:text/html\n\n
<!DOCTYPE html>
<html lange="en">
<head>
<title>Title</title>
</head>
<body>""")
def htmlTail():
print("""</body>
</html>""")
def getData():
formData = cgi.FieldStorage()
deploy_pro_name= formData.getvalue("deploy_process_name")
return deploy_pro_name
if __name__ == '__main__':
try:
htmlTop()
depl= getData()
print("DeployProcessName= {}".format(depl))
htmlTail()
except:
cgi.print_exception()
当我点击提交时,它只下载 filename.cgi。 我如何在点击提交后使其成为 运行 以下脚本?
看来你服务器端设置有误。 请严格按照服务器端 CGI 提供的任何内容(无论是 apache httpd、nginx、lighttpd 还是其他)
关注点:
- 脚本文件夹的所有权(用户:组)
- 脚本文件夹的权限
- 脚本的所有权(用户:组)
- 脚本权限
您似乎使用了默认扩展,但您是否确保已加载 CGI 模块并使用该扩展来处理 CGI?