View Full Version : python, setting variables

January 10th, 2009, 09:08 PM
I have a script that im running on my home server using apache and mod_python. What im attempting to do is call this script and pass it a post variable, but i cant seem to get the script to want to read this variable. wondering if someone could post some sample code on how to do this? thanks for any direction.

January 10th, 2009, 09:46 PM
How do you run that script? mod_python - seems like web app? As a response to HTTP request?

January 10th, 2009, 11:28 PM
Yeah mod_python might not mean much. But I do have a python script that I need to call via a http request and somehow setting the variable along the way, any suggestions or code refrences would be great.

January 11th, 2009, 01:13 AM
mod_python might be overkill. Use plain cgi module, it can access variables from GET and POST requests. You don't have to generate HTML page as response (but you can, for debugging: look at cgitb module: CGI traceback).

January 11th, 2009, 02:51 AM
thanks for the reply, but im still having problems getting python to read the post, something i think i need is cgi.FieldStorage() , am i right in this assumption. if so how exactly is this used ( sample code :) if you have any ) , thanks.