What is CGI?

CGI ဆိုတာကို ေတြ႔ဖူးေနျပီး ဘာမွန္း မသိျဖစ္ေနပါသလား။ကြ်န္ေတာ္လည္း အရင္ကမသိေပမယ့္ အခု blog ေရးဖုိ႔ ဖတ္ၾကည့္ျပီး တတ္ႏိုင္သေလာက္ျပန္ရွင္းျပလိုက္ပါတယ္။

CGI ဆိုတာ common gateway interface လို႔ေခၚပါတယ္။ သူ႔ကို အဓိကအားျဖင့္ web browser မွ request ေတြကို လက္ခံေပးဖို႔နဲ႔ server side programming ေတြရဲ႕ response ကို ျပန္ေပးပို႔ေပးဖို႔ သံုးပါတယ္။
CGI ဆိုတာ ဟာ programming language တစ္ခုမဟုတ္ပါဘူး။ ဒါေပမယ့္ ဘယ္ programming နဲ႔မဆို CGI script ကိုေရးလို႔ရပါတယ္။
အခုေခတ္မွာေတာ႔ CGI ဟာ အရမ္းေဟာင္းသြားျပီျဖစ္ပါတယ္။
PHP ကို စတင္ ဖန္တီးခဲ႔တဲ႔  Rasmus Lerdorf  ဟာလည္း သူ႔ personal homepage ေလးကို ျပင္ဆင္ထိန္းသိမ္းႏိုင္ ဖို႔အတြက္ CGI script ေတြကို C language နဲ႔ေရးခဲ႔ပါတယ္။အဲဒီေနာက္ ပိုမို ေကာင္းမြန္လာျပီး သီသန္႔ programming language တစ္ခု အျဖစ္ဖန္တီးလာခဲ႔တယ္။

Table 1.1. Tasks you can perform in CGI.
Task
CGI+HTML
HTML Alone
Handle forms
Yes
No
Create almost anything non-static that needs to be on a Web page
Yes
No
Handle imagemaps
Yes
Yes (but only with client side imagemapping)
Add searching to a Web page or set of documents
Yes
No
Create forms
Yes
Yes
Create platform-independent documents
Yes
Yes
Create applications such as chat rooms, voting booths, or anything interactive
Yes
No
Allow pages to be generated on the fly, making it easier to update a group of pages
Yes
No
Create documents tailored specifically to each user
Yes
No
Listing 1.1. How to print CGI environment variables in Perl. 
#!/usr/local/bin/perl
#Just returns an HTML Page with the words "Hello World" require "cgi-lib.pl"
print &PrintHeader;
print "<TITLE>Hello World</TITLE>"
print "Hello World<P>"
print &PrintEnv;exit;

Listing 1.2. How to print CGI environment variables in C.
#include <stdio.h>
#include "html-lib.h"
#include "cgi-lib.h"
int main()
{
  html_header();
  html_begin("Test CGI");
  h1("CGI Test Program");
  printf("<hr>\n");
  h2("CGI Environment Variables");
  print_cgi_env();
  html_end();
  return 0;
}
Listing 1.3. How to print CGI environment variables in C++. 
#define _DEBUG_DUMP_
#include "a_cgi.hpp"
main ()
{
  ACGI acgiOut;
  acgiOut.mimeHTML();
  acgiOut.cgiEnvironmentDump(0x1);     //a_Full dump!
  return 0x0;
}



 


Previous
Next Post »

Thorium School

Thorium School
Be professional with us