[Tutor] Python 2.5 and PHP 5.2.0

Christopher Arndt chris.arndt at web.de
Thu Feb 1 12:22:11 CET 2007


Luke Paireepinart schrieb:
> I can think of a roundabout way to do what you want:
> 
> PHP file returns a form to the client.  when this form is submitted to 
> the py file, all of the data your py script needs is sent in the query 
> string or whatever.
> the py file does whatever it does, and then inside the html it returns 
> to the client, it includes an instant redirect back to the PHP file with 
> whatever data you want to return.

The Python script can access the PHP page on the server directly, by
just making a request to localhost (if the PHP page is on the same
server). You could use urllib or some higher level HTTP client library
and pass the data to the PHP page either in a GET or POST request. The
PHP page looks just like any other web service to the Python script.
Based on the results from the request, it can then return HTML to the
client with a redirect to the PHP script, so the user can see the
updated data, or an error message.

Chris


More information about the Tutor mailing list