Python CGI

CGI stands for  Common Gateway Interface

It define a standard that define how the communication of information should be between the web server and a written script.

  1. A client, such as a web browser, sends an HTTP request to the web server.
  2. The web server routes the request to a Python CGI script, which is a program that is written in Python and executed on the server.
  3. The CGI script retrieves data, performs calculations, and generates an HTTP response, which is sent back to the web server.
  4. The web server returns the HTTP response to the client, which is displayed in the web browser.

This is a high-level overview of the basic architecture of a Python CGI application. In reality, the process is more complex, with many additional components and interactions, but this diagram provides a good starting point for understanding how a Python CGI application works.

Below is an example of Python CGI to build a simple application that allows users to add and view information about cars:

This code will handle incoming data from a form, add the data to a list of cars, and generate an HTML response that displays the list of cars and a form for adding new cars.

When this script is executed on the server, it will generate an HTML page that can be viewed in a web browser. The form allows users to add new cars by entering the make and model, and the table displays all of the cars that have been added. Each time the form is submitted, the information is added to the list, and the HTML response is updated to reflect the new data.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top