SlideShare a Scribd company logo
1 of 27
CGI Sopan Shewale , sopan.shewale@gmail.com
A few Assumptions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP short discussion ,[object Object],http:// www.persistentsys.com :80 /cgi/calender.cgi ? month=jan # week2 Scheme Host port Path Query Fragment ,[object Object]
HTTP short discussion (Cont…) ,[object Object],[object Object],[object Object],[object Object]
HTTP short discussion (Cont…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CGI: What is that? ,[object Object],[object Object],[object Object],[object Object]
How a CGI Applications Work?   CGI Application User Web Browser 1 2 3 4 HTTP Request HTTP Response CGI Program’s Response Call CGI Server Application  (on Server)
How a CGI Applications Work? ,[object Object],[object Object],[object Object]
Alternatives to CGI   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Alternatives to CGI (cont…) ,[object Object],[object Object],[object Object]
Configuring Apache to Permit CGI   ,[object Object],[object Object],[object Object],[object Object],[object Object],ScriptAlias /cgi-bin/ /usr/local/apache/cgi-bin /  <Directory /usr/local/apache/htdocs/somedir> Options +ExecCGI  </Directory >
CGI Environment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CGI Environment (Cont…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl   ,[object Object],[object Object],[object Object],[object Object],[object Object]
CGI.pm module ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],#!/usr/bin/perl use strict; use warnings; use CGI; my $q = new CGI(); print $q->header(&quot;text/html&quot;), $q->start_html(&quot;Welcome&quot;), $q->p(&quot;Welcome to the world of CGI&quot;), $q->end_html();
Handling Input with CGI.pm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Handling Output with CGI.pm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Handling Errors with CGI.pm ,[object Object],[object Object],[object Object],[object Object]
Maintaining State ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Authentication and Identification   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Count Click Script #!/usr/bin/perl # ######################### ## Author: Sopan Shewale ### This script is created for giving demo on click count. ## The Script is support to display increse/decrease click's, handles back button of browser, does not handle reload stuff. ## also it's based on sessions. ######################## use strict; use warnings; use CGI; use CGI::Session; use CGI::Cookie; my $q = new CGI(); my $sessionid = $q->cookie(&quot;CGISESSID&quot;) || undef; my $session = new CGI::Session(undef, $sessionid, {Directory=>'/tmp'}); $sessionid = $session->id(); my $cookie = new CGI::Cookie(-name=>'CGISESSID', -value=>$sessionid, -path=>&quot;/&quot;); print $q->header('text/html', -cookie=>$cookie); print $q->start_html(&quot;Welcome to Click Count Demo&quot;); print &quot;<h1>Welcome to Click Count Demo</h1>&quot;; my $count = $session->param('count');  ## count-is click count variable if(!defined($count)) { $session->param('count', 0);  $count=0;}  ### if session is first time created, set count=0 $session->param('count', $count); $count = $session->param('count'); #print &quot;<h1>The Click Count is: $count &quot;; ## Form stuff print $q->startform(-method=>'POST'); print $q->submit( -name=>&quot;Increase&quot;, -value=>'Increase1'); print $q->submit( -name=>&quot;Decrease&quot;, -value=>'Decrease1'); print $q->endform();
Example: Count Click Script (Cont…) ## Which button is being pressed my $which_button = $q->param('Increase'); if(defined ($which_button)) { print &quot;Increase pressed&quot;; $count = increase_count($count);  ## Increase the count since increase button is clicked $session->param('count', $count); }else { $which_button=$q->param('Decrease'); if(defined($which_button)){ print &quot;Decrease pressed&quot;; $count = decrease_count($count);  ## Decrease the count since decrease button is clicked $session->param('count', $count); } else {print &quot;You have not pressed any button, seems you are typing/re-typing the same URL&quot;; } } $count = $session->param('count'); print &quot;<h1>The Click Count is: $count &quot;; print $q->end_html(); ## increases the count by 1 sub increase_count { my $number = shift; $number = $number +1; return $number; } ## decreases the count by 1 sub decrease_count { my $number = shift; $number = $number -1; return $number; }
Example of Back- button Issue
What Next? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you For any queries write to  Email: sopan.shewale@gmail.com

More Related Content

What's hot (20)

CSS
CSS CSS
CSS
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Java script
Java scriptJava script
Java script
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
 
Intro to Three.js
Intro to Three.jsIntro to Three.js
Intro to Three.js
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
Animation
AnimationAnimation
Animation
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Autodesk maya presentation
Autodesk maya presentationAutodesk maya presentation
Autodesk maya presentation
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Object Oriented Programming Languages
Object Oriented Programming LanguagesObject Oriented Programming Languages
Object Oriented Programming Languages
 
Jquery
JqueryJquery
Jquery
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 

Similar to CGI Presentation

Similar to CGI Presentation (20)

Introduction to Web Programming with Perl
Introduction to Web Programming with PerlIntroduction to Web Programming with Perl
Introduction to Web Programming with Perl
 
Python cgi programming
Python cgi programmingPython cgi programming
Python cgi programming
 
Fm 2
Fm 2Fm 2
Fm 2
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
Copy of cgi
Copy of cgiCopy of cgi
Copy of cgi
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CI
 
How cgi scripting works
How cgi scripting worksHow cgi scripting works
How cgi scripting works
 
Cgi
CgiCgi
Cgi
 
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
 
php
phpphp
php
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
 
Perl web programming
Perl web programmingPerl web programming
Perl web programming
 
Slides serverside main
Slides serverside mainSlides serverside main
Slides serverside main
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
Manish
ManishManish
Manish
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

CGI Presentation

  • 1. CGI Sopan Shewale , sopan.shewale@gmail.com
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. How a CGI Applications Work? CGI Application User Web Browser 1 2 3 4 HTTP Request HTTP Response CGI Program’s Response Call CGI Server Application (on Server)
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. Example: Count Click Script #!/usr/bin/perl # ######################### ## Author: Sopan Shewale ### This script is created for giving demo on click count. ## The Script is support to display increse/decrease click's, handles back button of browser, does not handle reload stuff. ## also it's based on sessions. ######################## use strict; use warnings; use CGI; use CGI::Session; use CGI::Cookie; my $q = new CGI(); my $sessionid = $q->cookie(&quot;CGISESSID&quot;) || undef; my $session = new CGI::Session(undef, $sessionid, {Directory=>'/tmp'}); $sessionid = $session->id(); my $cookie = new CGI::Cookie(-name=>'CGISESSID', -value=>$sessionid, -path=>&quot;/&quot;); print $q->header('text/html', -cookie=>$cookie); print $q->start_html(&quot;Welcome to Click Count Demo&quot;); print &quot;<h1>Welcome to Click Count Demo</h1>&quot;; my $count = $session->param('count'); ## count-is click count variable if(!defined($count)) { $session->param('count', 0); $count=0;} ### if session is first time created, set count=0 $session->param('count', $count); $count = $session->param('count'); #print &quot;<h1>The Click Count is: $count &quot;; ## Form stuff print $q->startform(-method=>'POST'); print $q->submit( -name=>&quot;Increase&quot;, -value=>'Increase1'); print $q->submit( -name=>&quot;Decrease&quot;, -value=>'Decrease1'); print $q->endform();
  • 23. Example: Count Click Script (Cont…) ## Which button is being pressed my $which_button = $q->param('Increase'); if(defined ($which_button)) { print &quot;Increase pressed&quot;; $count = increase_count($count); ## Increase the count since increase button is clicked $session->param('count', $count); }else { $which_button=$q->param('Decrease'); if(defined($which_button)){ print &quot;Decrease pressed&quot;; $count = decrease_count($count); ## Decrease the count since decrease button is clicked $session->param('count', $count); } else {print &quot;You have not pressed any button, seems you are typing/re-typing the same URL&quot;; } } $count = $session->param('count'); print &quot;<h1>The Click Count is: $count &quot;; print $q->end_html(); ## increases the count by 1 sub increase_count { my $number = shift; $number = $number +1; return $number; } ## decreases the count by 1 sub decrease_count { my $number = shift; $number = $number -1; return $number; }
  • 24. Example of Back- button Issue
  • 25.
  • 26.
  • 27. Thank you For any queries write to Email: sopan.shewale@gmail.com