0

I have WAMP server set up for python cgi. But, I couldn't grab values from html form. I have marked where I get the error in python file. If I remove that line error goes.

HTML:

<body>

<h1>Fill out this form</h1>

<form action="test.py" method="POST">
     Enter your name: <input type="text" name="name">
     Enter age: <input type="text" name="age">

     <input type="submit" value="submit">
</form>

</body>

test.py:

#!C:\Python34\python

import cgitb
import cgi


form = cgi.FieldStorage()

print("""
<h1>Thanks for registering</h1>
""")

print("<p> form["name"].value")  # <--- If i remove this line the error goes

Error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable     to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
2
  • Looks like a syntax error to me Commented Apr 16, 2015 at 0:03
  • @BryanWay whats the error? i copy pasted everything from python doc Commented Apr 16, 2015 at 0:31

1 Answer 1

1

It's a syntax error. From this line:

print("<p> form["name"].value")

The string that's being printed is getting terminated early. Change it to:

print("<p>" + form["name"].value + "</p>")
Sign up to request clarification or add additional context in comments.

1 Comment

ohh i didn't paid attention to that closing paragraph tag. thanks a lot. Now i won't trust in copy pasting google docs code to the interpreter.

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.