How to create a simple CGI script? Last Updated : 27 Sep, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will explore how to create a simple CGI (Common Gateway Interface) script on a Windows machine but before that, we need some basic ideas about these technologies ( CGI Script, HTTP, Web Server ).CGI Script: A CGI script is a program that runs on a web server and generates dynamic web content. It's often used for processing web forms, interactive web applications, and server-side tasks.HTTP: Hypertext Transfer Protocol is the foundation of data communication on the World Wide Web. It defines how messages are formatted and transmitted.Web Server: A web server is software that serves web content to users, listening for incoming requests and responding by delivering web pages or running CGI scripts. Prerequisites: Please ensure that XAMPP is installed on your machine before continuing. If not then please refer to XAMPP installation in Windows. Creating CGI ScriptWe'll use the CGI directory provided by XAMPP "C:\xampp\cgi-bin" for storing the CGI script. Now create a new file with a .cgi extension and paste the following code into this new file. #!"C:\xampp\perl\bin\perl.exe" print "Content-Type: text/html\n\n"; print "<h1>Geeks For Geeks</h1>"; print "<p>This is a cgi-script</p>"; Running and Testing the CGI ScriptIn this section, we will run and test our CGI Script on web server using XAMPP. Step 1: Open XAMPP Control Panel from the start menu. Step 2: Click Config for the Apache module Step 3: Select Apache (httpd.conf) to edit the configuration file Step 4: Uncomment the line #AddHandler cgi-script .cgi .pl .aspIn this step, we will uncomment the line #AddHandler cgi-script .cgi .pl .asp if commented otherwise remain it as it is. Step 5: Save the file and restart the Apache serverWe will save the file and then restart the apache server such that the changes become save and Apache will run according to those changes. Step 6: Access the scriptWe can access the script through a web browser by navigating to "http://localhost/cgi-bin/gfg.cgi" in our Chrome web browser. Comment More infoAdvertise with us Next Article How to handle form data in CGI Scripts? J janav_makkar Follow Improve Article Tags : Python Python CGI Practice Tags : python Similar Reads How to Create Form using CGI script HTML forms are a fundamental part of web development, allowing users to input data and interact with web applications. Web developers often use Common Gateway Interface (CGI) scripts to process and send the data submitted through these forms. In this article, we'll explain what Python CGI scripts ar 3 min read How to generate webpages using CGI scripts? In this article, we will explore the process of generating webpages using CGI scripts. Furthermore, we will discuss the importance of CGI script implementation in facilitating dynamic content creation. Additionally, we'll delve into the intricacies of linking one page to another by creating multiple 4 min read Create Basic Webpage with Pyscript In this article, we will cover how we can create a basic webpage with Pyscript The Pyscript is a python framework/library that allows us to write python code inside HTML directly with the help[ of pyscript tag. Pyscript is a new project and is currently under development, but it has gained a lot of 5 min read How to Execute SQL queries from CGI scripts In this article, we will explore the process of executing SQL queries from CGI scripts. To achieve this, we have developed a CGI script that involves importing the database we created. The focus of this discussion will be on writing code to execute SQL queries in Python CGI scripts. The initial step 5 min read How to handle form data in CGI Scripts? In this article, we'll guide you through the process of creating a registration form in HTML and then using a CGI script to fetch and display the submitted user data in the form of a card, along with a success message. Registration forms are a fundamental component of many web applications, allowing 4 min read How To Enable or Disable CGI Scripts in Apache? This article will guide you on how to enable or disable CGI scripts in Apache. Configuring CGI scripts in Apache is a crucial aspect of managing dynamic content generation on web servers. The Common Gateway Interface (CGI) provides a standardized protocol for executing programs, allowing websites to 4 min read Like