Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain how to make Forms in python.

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


Please Help Members By Posting Answers For Below Questions

What is the other way of checking truthiness?

848


Mention what is flask-wtf and what are their features?

860


What are class methods?

756


Why is python oop?

774


What is a string in python?

768


Tell us something about python iterators.

753


What is a script mode?

868


Name the arithmetic operators supported by python.

883


What does the __ init__ function do in python?

939


What is the pythonpath variable?

889


Which is more powerful python or c++?

769


How to sort a dictionary by value in python?

785


What is numpy shape?

769


What command do we use to debug a python program?

836


What is the maximum possible length of an identifier?

848