What is the python CGI environment setup? Detailed description of Python CGI programming with examples

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.