Explain how to make Forms in python.



Explain how to make Forms in python...

Answer / 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

More Python Interview Questions

What is super method in python?

0 Answers  


What are all important modules in python reuired for a data science ?

0 Answers  


How do I run python setup py?

0 Answers  


Define monkey patching?

0 Answers  


What are magic methods in python?

0 Answers  






Print the length of each line in the file ‘file.txt’ not including any whitespaces at the end of the lines?

0 Answers  


How many variables are in python?

0 Answers  


Should I learn r or python?

0 Answers  


What is difference between pass and continue in python?

0 Answers  


What is the procedure to extract values from the object used in python?

1 Answers   LeapZen,


What is the comment tag in Python ?

0 Answers   Microsoft,


What is print format value interpolation?

0 Answers  


Categories