apply some code analyzer recommendations ICU flag now check if libicu exists prepare for more accurate growth of containers (limited PoT, then constantly increase size)
85 lines
2.5 KiB
C++
85 lines
2.5 KiB
C++
#include "pip.h"
|
|
|
|
using namespace PICoutManipulators;
|
|
|
|
PIKbdListener kbd;
|
|
const char * pageTitle = "<!DOCTYPE html>"
|
|
"<html>"
|
|
"<body>"
|
|
"<h1>Title</h1>"
|
|
"</body>"
|
|
"</html>";
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
// piCout << PIString::readableSize(PISystemMonitor::usedRAM());
|
|
|
|
PIVector<int> vi;
|
|
piForTimes(10) {
|
|
piSleep(2.);
|
|
vi.enlarge(1000000);
|
|
piCout << "now" << vi.size() << vi.capacity();
|
|
}
|
|
|
|
piSleep(5.);
|
|
/*kbd.enableExitCapture();
|
|
|
|
PIHTTPServer server;
|
|
|
|
server.setFavicon(PIFile::readAll("logo.png", false));
|
|
// server.setOption(MicrohttpdServer::Option::HTTPSEnabled, true);
|
|
server.listen({"127.0.0.1", 7777});
|
|
// server.listen({"192.168.1.10", 7778});
|
|
|
|
server.registerPath("/", MicrohttpdServer::Method::Get, [](const MicrohttpdServer::Request & r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply ret;
|
|
ret.setBody(PIByteArray::fromAscii(pageTitle));
|
|
return ret;
|
|
});
|
|
|
|
server.registerPath("/html", MicrohttpdServer::Method::Get, [](const MicrohttpdServer::Request & r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply ret;
|
|
ret.setBody("<!DOCTYPE html><html><body><p>arg=%1</p></body></html>"_a.arg(r.args.value("a0")).toUTF8());
|
|
return ret;
|
|
});
|
|
|
|
server.registerPath("/api", MicrohttpdServer::Method::Put, [](const MicrohttpdServer::Request & r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply ret;
|
|
ret.setBody(PIByteArray::fromAscii("<!DOCTYPE html><html><body>API</body></html>"));
|
|
return ret;
|
|
});
|
|
|
|
server.registerPath("/api/", MicrohttpdServer::Method::Post, [](const MicrohttpdServer::Request & r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply ret;
|
|
ret.setBody("<!DOCTYPE html><html><body>API etry %1</body></html>"_a.arg(r.path).toUTF8());
|
|
ret.setCode(405);
|
|
return ret;
|
|
});
|
|
|
|
server.registerUnhandled([](const MicrohttpdServer::Request & r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply ret;
|
|
ret.setBody("<!DOCTYPE html><html><body>Unknown</body></html>"_a.arg(r.path).toUTF8());
|
|
ret.setCode(404);
|
|
return ret;
|
|
});*/
|
|
|
|
/*server.setRequestCallback([](MicrohttpdServer::Request r) -> MicrohttpdServer::Reply {
|
|
MicrohttpdServer::Reply rep;
|
|
piCout << "request" << r.path;
|
|
piCout << " header" << r.headers;
|
|
piCout << " args" << r.args;
|
|
piCout << " body" << r.body;
|
|
piCout << "";
|
|
rep.setBody(PIByteArray::fromAscii("[{\"value1\": true, \"value2\": \"ыекштп\"}]"));
|
|
return rep;
|
|
});*/
|
|
|
|
/*piCout << "start" << server.isListen();
|
|
|
|
WAIT_FOR_EXIT
|
|
|
|
server.stop();*/
|
|
|
|
return 0;
|
|
}
|