Web 浏览

Web 浏览
为了更好地了解 CGI 的概念,让我们点击一个超链接,浏览一个特定的网页或 URL,看看会发生什么。

您的浏览器联系上 HTTP Web 服务器,并请求 URL,即文件名。
Web 服务器将解析 URL,并查找文件名。如果找到请求的文件,Web 服务器会把文件发送回浏览器,否则发送一条错误消息,表明您请求了一个错误的文件。
Web 浏览器从 Web 服务器获取响应,并根据接收到的响应来显示文件或错误消息。
然而,以这种方式搭建起来的 HTTP 服务器,不管何时请求目录中的某个文件,HTTP 服务器发送回来的不是该文件,而是以程序形式执行,并把执行产生的输出发送回浏览器显示出来。

公共网关接口(CGI),是使得应用程序(称为 CGI 程序或 CGI 脚本)能够与 Web 服务器以及客户端进行交互的标准协议。这些 CGI 程序可以用 Python、PERL、Shell、C 或 C++ 等进行编写。

 1 #include <iostream>
 2 #include <string.h> 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 int main(int argc, char** argv) {
 6     string string1,string2,string3,temp;
 7     cout <<"please input three strings:";
 8     cin>>string1>>string2>>string3;
 9     if(string2>string3){
10         temp=string2;
11         string2=string3;
12         string3=temp;
13     }
14     
15     if(string1<=string2)
16     cout<<string1<<" "<<string2<<" "<<string3<<endl;
17     else if(string1<=string3) 
18     cout<<string2<<" "<<string1<<" "<<string3<<endl;
19     else 
20     cout<<string2<<" "<<string3<<" "<<string1<<endl;
21     return 0;
22 }
原文地址:https://www.cnblogs.com/borter/p/9401326.html