Home
О нас
Products
Services
Регистрация
Войти
Поиск
infolan
@infolan
October 2023
1
5
Report
как написать основу для сайта на с++ (дам 100 баллов)
Please enter comments
Please enter your name.
Please enter the correct email address.
Agree to
terms of service
You must agree before submitting.
Send
Answers & Comments
glitkoglitko180
Ответ:
На 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;
}
1 votes
Thanks 0
infolan
сяб бро
More Questions From This User
See All
infolan
November 2023 | 0 Ответы
185 6
Answer
infolan
October 2023 | 0 Ответы
1 i 40 653aeb5bc3245
Answer
×
Report "как написать основу для сайта на с++ (дам 100 баллов)"
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Helpful Links
О нас
Политика конфиденциальности
Правила и условия
Copyright
Контакты
Helpful Social
Get monthly updates
Submit
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
На 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;
}