What's good about Python programming in the previous article? Learn about the hottest Python CGI programming of the moment we have a brief introduction to what is
Python CGI programming,This article is an in-depth understanding and
Python CGI Programming detailedAnd
Python CGI environment construction,
Web server support and configuration
Before you perform CGI programming, make sure that your Web server supports CGI and a CGI-configured handler.
Apache supports CGI configuration:
Set up the CGI directory:
scriptalias/cgi-bin//var/www/cgi-bin/
All HTTP server execution CGI programs are saved in a pre-configured directory. This directory is called the CGI directory and, by convention, it is named the/var/www/cgi-bin directory.
CGI files with the. cgi,python extension can also use the. py extension.
By default, the Linux server configuration runs in the Cgi-bin directory as/var/www.
If you want to specify other directories that run CGI scripts, you can modify the httpd.conf configuration file as follows:
<directory "/var/www/cgi-bin" > allowoverride None Options +execcgi Order allow,deny allow From all</directory>
Add the. py suffix in AddHandler so that we can access the Python script file at the end of the. PY:
AddHandler cgi-script. cgi. pl. py
CGI Environment variables
All CGI programs receive the following environment variables, which play an important role in CGI programs: