I'm trying to write a quick HTML form:
<!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>
and I wrote the following script in python using cgi package to extract the data from the form and handle it: For example - Getting the 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()
When I click submit, it just downloads the filename.cgi. How do I make it run the following script once hitting submit?