What is CGI?
Common Gateway Interface (also known as CGI) is not a kind of language but just a specification(set of rules) that helps to establish a dynamic interaction between a web application and the browser (or the client application). The CGI programs make possible communication between client and web servers. Whenever the client browser sends a request to the webserver the CGI programs send the output back to the web server based on the input provided by the client-server.
- CGI is the standard for programs to interface with HTTP servers.
- CGI programming is written dynamically generating webpages that respond to user input or webpages that interact with software on the server
Working of CGI
When a request is made by the client-server to the webserver, the CGI uses external script files to handle such requests. These files could be written in any language. The main objective of these script files is to retrieve the data from the database quickly and more efficiently. These scripts convert the retrieved data into an Html format that sends the data to these web servers in Html formatted page.
Install apache2 on your system can we will run ‘hello.py’ on host ‘127.0.0.1’
It is recommended to have basic knowledge of HTML before trying this example.
Some advantages of CGI are discussed as below:
1 They are portable and can work on almost any web server and operating system.
2 They are language-independent.
3 They are quite scalable programs in nature which means they can perform both simple and complex tasks.
4 CGIs enhance dynamic communication in web applications.
5They also aid in making businesses more profitable by decreasing development and maintenance costs.
Some disadvantages of CGI are as below:
1 The interpreter has to evaluate a CGI script every time the program is initiated this creates a lot of traffic as there are too many requests from the side of the client-server.
2 Programming and designing of CGI programs is very complex and ambiguous.
3 CGI programs may compromise server security as most of them are free and easily available making them quite vulnerable.
This article is contributed by Harsh Wardhan Chaudhary (Intern). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2
- Time Functions in Python | Set-2 (Date Manipulations)
- Send mail from your Gmail account using Python
- Python – The new generation Language
- Print Single and Multiple variable in Python
- Increment and Decrement Operators in Python
- str() vs repr() in Python
- Swap two variables in one line in C/C++, Python, PHP and Java
- Generate all permutation of a set in Python
- Class or Static Variables in Python
- trunc() in Python
- Division Operators in Python
- Interesting facts about strings in Python | Set 1
- When to use yield instead of return in Python?
- How to split a string in C/C++, Python and Java?
- Interesting facts about strings in Python | Set 2 (Slicing)
- Returning Multiple Values in Python
- String Template Class in Python
- Python List Comprehension and Slicing