Hello World! 这是我的第一个 CGI 程序

Hello World! 这是我的第一个 CGI 程序
上面的 C++ 程序是一个简单的程序,把它的输出写在 STDOUT 文件上,即显示在屏幕上。在这里,值得注意一点,第一行输出 Content-type:text/html\r\n\r\n。这一行发送回浏览器,并指定要显示在浏览器窗口上的内容类型。您必须理解 CGI 的基本概念,这样才能进一步使用 Python 编写更多复杂的 CGI 程序。C++ CGI 程序可以与任何其他外部的系统(如 RDBMS)进行交互。

 

 1 #include <iostream>
 2 using namespace std;
 3  
 4 int main ()
 5 {
 6     
 7    cout << "Content-type:text/html\r\n\r\n";
 8    cout << "<html>\n";
 9    cout << "<head>\n";
10    cout << "<title>Hello World - 第一个 CGI 程序</title>\n";
11    cout << "</head>\n";
12    cout << "<body>\n";
13    cout << "<h2>Hello World! 这是我的第一个 CGI 程序</h2>\n";
14    cout << "</body>\n";
15    cout << "</html>\n";
16    
17    return 0;
18 }

 

posted @ 2018-08-01 15:07  borter  阅读(155)  评论(0编辑  收藏  举报