emsApplication/applications/WebConfigure/cgiCommon/main.cpp

81 lines
1.7 KiB
C++

#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);
// 添加更多处理函数...
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();
}
int main()
{
using namespace cgicc;
using namespace std;
Cgicc formData;
#if 0
handleLoginRequest(formData);
return 0;
#endif
#if 1
//获得api方法
form_iterator fi = formData.getElement("do");
if (!fi->isEmpty() && fi != (*formData).end())
{
if (**fi == "version")
{
handleVersion(formData);
}
if (**fi == "login")
{
handleLoginRequest(formData);
}
if (**fi == "getDevices")
{
}
}
return 0;
#endif
}