• Предмет: Информатика
  • Автор: infolan
  • Вопрос задан 3 месяца назад

как написать основу для сайта на с++ (дам 100 баллов)

Ответы

Ответ дал: glitkoglitko180
0

Ответ:

На Debian и Ubuntu установить библиотеку и заголовки можно с помощью:

apt install libcgicc5 libcgicc5-dev

Но на CentOS / RHEL нет собственных пакетов. Чтобы установить на них, запустите:

cd /usr/local/src

wget ftp://ftp.gnu.org/gnu/cgicc/cgicc-3.2.19.tar.gz

tar xfz cgicc*.tar.gz

cd cgicc*

./configure — prefix=/usr

make

make install

Makefile:

all:

       g++ -O3 -s hello.cpp -o hello.cgi

       g++ -O3 -s cgicc.cpp -o cgicc.cgi /usr/lib/libcgicc.a

clean:

       rm -f hello.cgi cgicc.cgi

cgicc.html:

<!doctype html>

<html lang="en">

<head>

 <title>cgicc Test</title>

</head>

<body>

 <form method="POST" action="cgicc.cgi">

   <label for="name">Name</label>

   <input name="name" type="text" value="">

   <input name="submit" type="submit" value="Submit">

 </form>

</body>

</html>

cgicc.cpp:

#include <iostream>

#include <string>

#include <stdio.h>

#include <stdlib.h>

#include <cgicc/CgiDefs.h>

#include <cgicc/Cgicc.h>

#include <cgicc/HTTPHTMLHeader.h>

#include <cgicc/HTMLClasses.h>

using namespace std;

using namespace cgicc;

void set_content_type(string content_type) {

 cout << "Content-type: " << content_type << "\r\n\r\n";

}

void set_page_title(string title) {

 cout << "<title>" << title << "</title>\n";

}

void h1_text(string text) {

 cout << text << "\n";

}

int main() {

 Cgicc cgi;

 string name;

 set_content_type("text/html");

 cout << "<!doctype html>\n";

 cout << "<html lang=\"en\">\n";

 cout << "<head>\n";

 set_page_title("cgicc Test");

 cout << "</head>\n";

 cout << "<body>\n";

 cout << "<p>";

 // Grab the "name" variable from the form

 name = cgi("name");

 // Check to make sure it isn’t empty.

 if (!name.empty()) {

   cout << "Name is " << name << "\n";

 } else {

   cout << "Name was not provided.";

 }

 cout << "</p>\n";

 cout << "</body>\n";

 cout << "</html>";

 return 0;

}


infolan: сяб бро
Вас заинтересует