GNU Free Documentation License . .

CGI

: ,

CGI ( . Common Gateway Interface  « »)  , -. , -, , «» () «CGI-».

, , /. , , , .

, , cgi ( cgi-bin) , : , - . - Apache, , httpd.conf .htaccess , .

CGI -.

[]

Hello World Python:

#!/usr/bin/python
import sys
try: 
    import cgitb
    cgitb.enable()
except ImportError:
    sys.stderr = sys.stdout
 
def cgiprint(inline=''):
    sys.stdout.write(inline)
    sys.stdout.write('\r\n')
    sys.stdout.flush()           
 
contentheader = 'Content-Type: text/html'
 
thepage = '''<html><head>
<title>%s</title>
</head><body>
%s
</body></html>
'''
h1 = '<h1>%s</h1>'
 
if __name__ == '__main__':
    cgiprint(contentheader)   #  
    cgiprint()                #         
 
    title = 'Hello World'
    headline = h1 % 'Hello, world!'
 
    print thepage % (title, headline)   #   html

Pascal:

  1. Program first;
    
  2. Begin
    
  3.   Writeln('Content-type: text/plain');
    
  4.   Writeln;
    
  5.   Writeln('Hello, world!');
    
  6. End.
    

Hello World C:

#include <stdio.h>
int main(void) {
  printf("Content-Type: text/plain;charset=us-ascii\n\n");
  printf("Hello, world!\n\n");
  return 0;
}

[] .

[]

[]