I have the following html button
<td><form id="form2" name="form2" method="post" onclick="../cgi-bin/py/GuestBookEntry.py">
<input type="submit" name="gBookSrib" id="gBookSrib" value="Sribble" />
</form></td>
My python script is
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html><body>Hello World!</body></html>
When i click the button i want my serverside script to execute and create a html page. How do i do that?
My webhost service provider is fatcow. I think he runs apache, is there a way to check it though? Yes he supports python cgi script. He mentioned that if i place my ‘py’ files inside the cgi-bin, it should work, even without the ‘she’bang.
Fatcow does not allow custom modules. Only standard python modules. They had not allowed access to my cgi-bin folder by default, so had to call them, and then the below stuff just worked.
Which web server are you using?
For apache2 there is very tidy module called apache2-modpython, that takes care of executing server-side python scripts and returning the result to the client.
Using this module your python would look like:
Let’s say this script is called test.py and has the URI http://yourserver.tld/test.py, then your form would look like:
Inside the entry of your site definition add the following lines