Common gateway interface (CGI): Difference between revisions
Mr. MacKenty (talk | contribs) No edit summary |
Mr. MacKenty (talk | contribs) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[file:Connection.png|right|frame|Web Science<ref>http://www.flaticon.com/</ref>]] | [[file:Connection.png|right|frame|Web Science<ref>http://www.flaticon.com/</ref>]] | ||
<center> | |||
<blockquote style="padding: 5px; background-color: #FFF8DC; border: solid thin gray;"> | |||
[[File:Exclamation.png]] CGI can also refer to computer generated imagery. We aren't talking about this here. | |||
</blockquote> | |||
</center> | |||
In computing, Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs that execute like Console applications (also called Command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The specifics of how the script is executed by the server are determined by the server. In the common case, a CGI script executes at the time a request is made and generates HTML.<ref>https://en.wikipedia.org/wiki/Common_Gateway_Interface#See_also</ref> | In computing, Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs that execute like Console applications (also called Command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The specifics of how the script is executed by the server are determined by the server. In the common case, a CGI script executes at the time a request is made and generates HTML.<ref>https://en.wikipedia.org/wiki/Common_Gateway_Interface#See_also</ref> | ||
CGI allows a script on a web server to process input (for example, from a form) and return results to a requester. | |||
== Diagram == | |||
[[File:Cgi diagram.png]] | |||
# The Web surfer fills out a form and clicks, “Submit.” The information in the form is sent over the Internet to the Web server. | |||
# The Web server “grabs” the information from the form and passes it to the CGI software. | |||
# The CGI software performs whatever validation of this information that is required. For instance, it might check to see if an e-mail address is valid. If this is a database program, the CGI software prepares a database statement to either add, edit, or delete information from the database. | |||
# The CGI software then executes the prepared database statement, which is passed to the database driver. | |||
# The database driver acts as a middleman and performs the requested action on the database itself. | |||
# The results of the database action are then passed back to the database driver. | |||
# The database driver sends the information from the database to the CGI software. | |||
# The CGI software takes the information from the database and manipulates it into the format that is desired. | |||
# If any static HTML pages need to be created, the CGI program accesses the Web server computer’s file system and reads, writes, and/or edits files. | |||
# The CGI software then sends the result it wants the Web surfer’s browser to see back to the Web server. | |||
# The Web server sends the result it got from the CGI software back to the Web surfer’s browser. | |||
== Real world, practical advice == | == Real world, practical advice == | ||
In the past we used cgi to create dynamic webpages. We needed a way to run perl or shell scripts. A web client would send a request via cgi and the webserver would process the script and return the results of the script. With the rise of purpose-built scripting languages, I don't see cgi used often. Real world practical advice: if you are working with a system with cgi-bin you should wonder what requirements are driving the use. Often there are [[Legacy system legacy]] issues you should be aware of. | In the past we used cgi to create dynamic webpages. We needed a way to run perl or shell scripts. A web client would send a request via cgi and the webserver would process the script and return the results of the script. With the rise of purpose-built server-side web-based scripting languages (PHP, ASP), I don't see cgi used often. Real world practical advice: if you are working with a system with cgi-bin you should wonder what requirements are driving the use. Often there are [[Legacy system| legacy]] issues you should be aware of. | ||
If you see web files ending with .cgi or .pl you may be working with cgi. | |||
== Do you understand this? == | == Do you understand this? == |
Latest revision as of 06:07, 2 May 2017
CGI can also refer to computer generated imagery. We aren't talking about this here.
In computing, Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs that execute like Console applications (also called Command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The specifics of how the script is executed by the server are determined by the server. In the common case, a CGI script executes at the time a request is made and generates HTML.[2]
CGI allows a script on a web server to process input (for example, from a form) and return results to a requester.
Diagram[edit]
- The Web surfer fills out a form and clicks, “Submit.” The information in the form is sent over the Internet to the Web server.
- The Web server “grabs” the information from the form and passes it to the CGI software.
- The CGI software performs whatever validation of this information that is required. For instance, it might check to see if an e-mail address is valid. If this is a database program, the CGI software prepares a database statement to either add, edit, or delete information from the database.
- The CGI software then executes the prepared database statement, which is passed to the database driver.
- The database driver acts as a middleman and performs the requested action on the database itself.
- The results of the database action are then passed back to the database driver.
- The database driver sends the information from the database to the CGI software.
- The CGI software takes the information from the database and manipulates it into the format that is desired.
- If any static HTML pages need to be created, the CGI program accesses the Web server computer’s file system and reads, writes, and/or edits files.
- The CGI software then sends the result it wants the Web surfer’s browser to see back to the Web server.
- The Web server sends the result it got from the CGI software back to the Web surfer’s browser.
Real world, practical advice[edit]
In the past we used cgi to create dynamic webpages. We needed a way to run perl or shell scripts. A web client would send a request via cgi and the webserver would process the script and return the results of the script. With the rise of purpose-built server-side web-based scripting languages (PHP, ASP), I don't see cgi used often. Real world practical advice: if you are working with a system with cgi-bin you should wonder what requirements are driving the use. Often there are legacy issues you should be aware of.
If you see web files ending with .cgi or .pl you may be working with cgi.
Do you understand this?[edit]
Describe the function of the common gateway interface (CGI).
Standards[edit]
These standards are used from the IB Computer Science Subject Guide[3]
- Describe the function of the common gateway interface (CGI).
References[edit]
- ↑ http://www.flaticon.com/
- ↑ https://en.wikipedia.org/wiki/Common_Gateway_Interface#See_also
- ↑ IB Diploma Programme Computer science guide (first examinations 2014). Cardiff, Wales, United Kingdom: International Baccalaureate Organization. January 2012.