Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. CGI in python
  5. CGI environment variable

CGI environment variable

The full form of CGI is Common Gateway Interface. It is a set of standards that define how information is exchanged between the web server and a custom script.

The Common Gateway Interface is a standard for external gateway programs to interface with the server, such as HTTP Servers.

The data retrieved from the databases is converted in HTML format and sent to the webserver.

Taking a look at the CGI architecture when a request is made to the web server from the client server the common gateway interface uses external files or program to handle such requests and these programs or files can be written in any programming language but the main goal of these program is to retrieve data from the databases.

And the data retrieved from the databases is converted in HTML format and sent to the web server.

Environment variables are a series of hidden values that the web server send to every CGI program you run.

Your program can pass them and use the data they send. So we have a document root which is the root directory of your server, and then we have an STD cookie which is the visitor’s if one is set for them.

Some environment variables are:-

  • CONTENT_TYPE – The data type of the content. Used when the client is sending attached content to the server. For example, file upload.
  • CONTENT_LENGTH – The length of the query information. It is available only for POST requests.
  • HTTP_COOKIE – Returns the set cookies in the form of key & value pair.
  • HTTP_USER_AGENT – The User-Agent request-header field contains information about the user agent originating the request. It is the name of the web browser.
  • SCRIPT_NAME – The name of the CGI script.

This is all about environment variables.

Was this article helpful to you? Yes No 1

How can we help?