2024-05-24 12:19:45 +08:00
|
|
|
|
#include <cgicc/Cgicc.h>
|
|
|
|
|
#include <cgicc/CgiDefs.h>
|
|
|
|
|
#include <cgicc/HTTPHTMLHeader.h>
|
|
|
|
|
#include <cgicc/HTMLClasses.h>
|
|
|
|
|
|
|
|
|
|
#include "handleHeader.h"
|
|
|
|
|
|
|
|
|
|
// 你的CGI处理函数声明
|
|
|
|
|
void handleLoginRequest(cgicc::Cgicc& cgi);
|
|
|
|
|
void handleSignupRequest(cgicc::Cgicc& cgi);
|
|
|
|
|
|
|
|
|
|
// 添加更多处理函数...
|
|
|
|
|
|
2024-06-04 13:36:17 +08:00
|
|
|
|
void handleVersion(cgicc::Cgicc& cgi)
|
|
|
|
|
{
|
|
|
|
|
using namespace cgicc;
|
|
|
|
|
using namespace std;
|
|
|
|
|
// Output the HTTP headers for an HTML document, and the HTML 4.0 DTD info
|
|
|
|
|
std::cout << HTTPHTMLHeader() << HTMLDoctype(HTMLDoctype::eStrict) << std::endl;
|
|
|
|
|
|
|
|
|
|
//cout << html().set("lang", "en").set("dir", "ltr") << endl;
|
|
|
|
|
std::cout << "<meta charset=\"UTF-8\">" << std::endl;
|
|
|
|
|
|
|
|
|
|
// Set up the page's header and title.
|
|
|
|
|
std::cout << head() << std::endl;
|
|
|
|
|
std::cout << title() << "Shanghai Huijue EMS device" << title() << std::endl;
|
|
|
|
|
std::cout << head() << std::endl << std::endl;
|
|
|
|
|
|
|
|
|
|
std::cout << body() << std::endl;
|
|
|
|
|
|
|
|
|
|
//std::cout << h1("Version 1.0.531") << std::endl;
|
|
|
|
|
#define cgiVersion "1.0.531"
|
|
|
|
|
|
|
|
|
|
const char* VersionInfo = "Version: " cgiVersion;
|
|
|
|
|
const char* BuildInfo = "Build Info: " __DATE__ " " __TIME__;
|
|
|
|
|
|
|
|
|
|
std::cout << h1(VersionInfo) << std::endl;
|
|
|
|
|
std::cout << h1(BuildInfo) << std::endl;
|
|
|
|
|
|
|
|
|
|
// Close the document
|
|
|
|
|
std::cout << body() << html();
|
|
|
|
|
|
|
|
|
|
}
|
2024-05-24 12:19:45 +08:00
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
using namespace cgicc;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
Cgicc formData;
|
2024-06-04 13:36:17 +08:00
|
|
|
|
#if 0
|
|
|
|
|
handleLoginRequest(formData);
|
2024-05-24 12:19:45 +08:00
|
|
|
|
|
2024-06-04 13:36:17 +08:00
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
2024-05-24 12:19:45 +08:00
|
|
|
|
//获得api方法
|
|
|
|
|
form_iterator fi = formData.getElement("do");
|
|
|
|
|
|
|
|
|
|
if (!fi->isEmpty() && fi != (*formData).end())
|
|
|
|
|
{
|
2024-06-04 13:36:17 +08:00
|
|
|
|
if (**fi == "version")
|
|
|
|
|
{
|
|
|
|
|
handleVersion(formData);
|
|
|
|
|
}
|
2024-05-24 12:19:45 +08:00
|
|
|
|
|
|
|
|
|
if (**fi == "login")
|
|
|
|
|
{
|
|
|
|
|
handleLoginRequest(formData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (**fi == "getDevices")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2024-06-04 13:36:17 +08:00
|
|
|
|
#endif
|
2024-05-24 12:19:45 +08:00
|
|
|
|
}
|