- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
CGI Environment Variables in Python
All the CGI programs have access to the following environment variables. These variables play an important role while writing any CGI program.
|Sr.No.||Variable Name & Description|
The data type of the content. Used when the client is sending attached content to the server. For example, file upload.
The length of the query information. It is available only for POST requests.
Returns the set cookies in the form of key & value pair.
The User-Agent request-header field contains information about the user agent originating the request. It is name of the web browser.
The path for the CGI script.
The URL-encoded information that is sent with GET method request.
The IP address of the remote host making the request. This is useful logging or for authentication.
The fully qualified name of the host making the request. If this information is not available, then REMOTE_ADDR can be used to get IR address.
The method used to make the request. The most common methods are GET and POST.
The full path to the CGI script.
The name of the CGI script.
The server's hostname or IP Address
The name and version of the software the server is running.
Here is small CGI program to list out all the CGI variables.
#!/usr/bin/python import os print "Content-type: text/html\r
"; print "<font size=+1>Environment</font><\br>"; for param in os.environ.keys(): print "<b>%20s</b>: %s<\br>" % (param, os.environ[param])
- Perl CGI Environment Variables
- What are environment variables available in Python CGI Programming?
- Python Environment Variables
- MySQL Environment Variables
- C program to print environment variables
- Setting MySQL Environment Variables on Linux
- How to Use Environment Variables in Postman?
- Retrieve environment variables with Java Map Collection
- How to Set environment variables using PowerShell?
- What is CGI in Python?
- First CGI Program in Python
- Python Virtual Environment
- How do I pass environment variables to Docker containers?
- What Environment Variables are required to set in Java Applications?
- Using Cookies in CGI in Python