Accessing POST request data from CGIHTTPServer (python)

1.2k views Asked by At

I have a very simple CGI webserver running using python CGIHTTPServer class. This class spawns and executes a cgi-php script. If the webpage sends POST request, how can I access the POST request data in the php script?

1

There are 1 answers

2
AJ. On BEST ANSWER

When you say your Python process "spawns and executes" a cgi-php script, I believe what you mean is "it calls my PHP script by executing the PHP CLI executable, passing it the name of my script."

Using the PHP CLI executable, HTTP-specific superglobals and environment values will not be set automatically. You would have to read in all HTTP request headers and GET/POST data in your Python server process, and then set them in the environment used by your PHP script.

The whole experiment sounds interesting, but this is what mod_php does already.