我希望我解释正确..但我需要我的C ++程序才能显示HTML网站。我现在的代码只显示文本。我如何制作它实际上显示为一个网站(使用HTML代码)?我将使用上传到服务器的.exe文件来显示页面。
#include <iostream>
using namespace std;
int main()
{
cout << "Content-type: text/plain\n\n";
cout << "<h2>My first CGI program</h2>\n";
cout << "<h1>This is a test</h1>\n";
cout << "<h3>Why is this not working</h3>\n";
return 0;
}
答案 0 :(得分:2)
您的HTTP响应需要状态行,您应该将mime类型更改为text/html
:
cout << "HTTP/1.1 200 OK\n";
cout << "Content-Type: text/html\n\n";
cout << "<h2>My first CGI program</h2>\n";
cout << "<h1>This is a test</h1>\n";
cout << "<h3>Why is this not working</h3>\n";