Answer Posted / chaitanya
AAs python is scripting language forms processing is done by Python. We need to import cgi module to access form fields using FieldStorage class.
Every instance of class FieldStorage (for 'form') has the following attributes:
form.name: The name of the field, if specified.
form.filename: If an FTP transaction, the client-side filename.
form.value: The value of the field as a string.
form.file: file object from which data can be read.
form.type: The content type, if applicable.
form.type_options: The options of the 'content-type' line of the HTTP request, returned as a dictionary.
form.disposition: The field 'content-disposition'; None if unspecified.
form.disposition_options: The options for 'content-disposition'.
form.headers: All of the HTTP headers returned as a dictionary.
A code snippet of form handling in python:
import cgi
form = cgi.FieldStorage()
if not (form.has_key("name") and form.has_key("age")):
print "<H1>Name & Age not Entered</H1>"
print "Fill the Name & Age accurately."
return
print "<p>name:", form["name"].value
print "<p>Age:", form["age"].value
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How can we make a executable file with python script?
What is string slicing in python?
Can you use python to make apps?
Tell us what is the usage of help() and dir() function in python?
What is a python template engine?
What is python method?
What is a means by “tuple in python”?
What is pytest?
what are the two (2) parameters available in python map?
What is s in python 3?
How can you randomize the items of a list in place in python?
How will you check python version?
Write a program to play a guessing game using random module?
How are instance variables different from class variables?
Is there any way to kill a thread in python?