Open gymiyakawa opened 11 months ago
from subject.pdf Your server should work with one CGI (php-CGI, Python, and so forth).
Does that mean every script should be written in that particular language? or are theses pre-mde CGI programs we can interact or even call?
SCRIPTS for GET:
SCRIPTS for POST:
List which scripts we need, write them in the chosen language, store them in a /scripts
From wikipedia on CGI: edited.
A common convention is to have a cgi-bin/ directory at the base of the directory tree and treat all executable files within this directory (and no other, for security) as CGI scripts.
When a Web browser requests a URL that points to a file within the CGI directory (e.g., http://example.com/cgi-bin/printenv.pl/with/additional/path?and=a&query=string), then, instead of simply sending that file (/usr/local/apache/htdocs/cgi-bin/printenv.pl) to the Web browser, the HTTP server runs the specified script and passes the output of the script to the Web browser.
That is, anything that the script sends to standard output is passed to the Web client instead of being shown in the terminal window that started the web server.
Another popular convention is to use filename extensions; for instance, if CGI scripts are consistently given the extension .cgi, the Web server can be configured to interpret all such files as CGI scripts. While convenient, and required by many prepackaged scripts, it opens the server to attack if a remote user can upload executable code with the proper extension.
perhaps using .cgi42 ?
The CGI specification defines how additional information passed with the request is passed to the script. The Web server creates a subset of the environment variables passed to it and adds details pertinent to the HTTP environment.
For instance, if a slash and additional directory name(s) are appended to the URL immediately after the name of the script (in this example, /with/additional/path), then that path is stored in the PATH_INFO environment variable before the script is called.
If parameters are sent to the script via an HTTP GET request (a question mark appended to the URL, followed by param=value pairs; in the example, ?and=a&query=string), then those parameters are stored in the QUERY_STRING environment variable before the script is called. Request HTTP message body, such as form parameters sent via an HTTP POST request, are passed to the script's standard input.
The script can then read these environment variables or data from standard input and adapt to the Web browser's request.[9]