![]() |
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 ). 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 moduleStep 3: Select Apache (httpd.conf) to edit the configuration fileStep 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. |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |