How can we make forms in Python?

You have to import CGI module to access form fields using FieldStorage class.

Attributes of class FieldStorage for the form:

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 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.

import cgi
form = cgi.FieldStorage()
if not (form.has_key(“name”) and form.has_key(“age”)):
print

Name & Age not Entered


print “Fill the Name & Age accurately.”
return
print

name:”, form[“name”].value
print

Age:”, form[“age”].value