0

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?

1 Answer 1

1

It seems you have incorrectly set up server end. Please follow whatever you're server side CGI is served with to the letter (be it apache httpd, nginx, lighttpd, or whatever)

Things to focus on:

  • ownership (user:group) of the scripts folder
  • permissions of the scripts folder
  • ownership (user:group) of the script
  • permissions of the script

you seem to have used default extension, but did you ensure the CGI module is loaded and is using that extension to handle CGI?

Sign up to request clarification or add additional context in comments.

2 Comments

Any references to CGI module extension handling? I'm working with IIS on windows and I'm using a local server
you should refer to the documentation of IIS. the IIS server is shipped by Microsoft. They have excellent documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.