Get html form values into python through CGI

I modified the HTML file and made the python file containing those HTML tags. But when applying bootstrap CSS to that file, it was not picking up the CSS file from the same cgi-bin folder. So I placed it in the localhost and it worked.

So, to get the form values through CGI, first I did:

import cgi, cgitb


form = cgi.FieldStorage()


For example, the name attribute of an input field is defined as ‘Soil_type’ in the HTML tags. Hence, we can get the value entered in that input field by:

value = form.getvalue('Soil_type')

Also, I got some added a line:

os.system("octave program.m > output")

The above code was for executing a shell command through python. It was working on my system but giving some error on the server. It may be due to some different configuration on the server than my laptop.

Github Repository link:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close