What is Python CGI programming? What do I need to prepare before programming?

Source: Internet
Author: User
Tags prepare python script
In this article, let's take a look at python ProgrammingKnowledge, some friends may have just come into contact with Python, the programming language, for Python programming from the beginning to the relevant aspects of the practice of understanding relatively little, this article we will talk about Python programming knowledge.

Python CGL programming

What is CGL:

CGI is currently maintained by NCSA, and NCSA defines CGI as follows:

CGI (Common Gateway Interface), a universal Gateway interface, is a program that runs on a server such as an HTTP server, providing an interface with the client HTML page.

Web browsing

To get a better idea of how CGI works, we can click on a link or URL from the Web page:

1. Use your browser to access the URL and connect to the HTTP Web server.

2. When the Web server receives the request information, it resolves the URL and finds whether the file accessed exists on the server and returns an error message if there is the contents of the returned file.

3. The browser receives the information from the server and displays the received file or error message.

CGI programs can be Python scripts, Perl scripts, shell scripts, C or C + + programs, and so on.

The composition of the CGL frame is as follows :

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
Related Article

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.