Posting html form values to python script

in the form action form action="", put the location of your cgi script and the value of the textbox will be passed to the cgi script.
eg.

<form name="search" action="/cgi-bin/test.py" method="get">
Search: <input type="text" name="searchbox">
<input type="submit" value="Submit">
</form> 

in your test.py

import cgi
form = cgi.FieldStorage()
searchterm =  form.getvalue('searchbox')

thus you will get the key word entered in search text box in searchterm variable in python.

Leave a Comment