Dear ROOT community!
I’d like to know how to correctly make use of Register
and RegisterCommand
functions of the THttpServer Class within a cmake compiled project.
I have two different web pages (A and B) and things work well when I lunch each of those pages separately in two different ports. However, when I open only one port (let’s say the on of A), and lunch a command from the web page B: it doesn’t work anymore! The command is sent but it not found (Error 404 in the page console), I suspect that something went wrong on how I use Register
and RegisterCommand
. Here is a simplified version of my code:
In my c++ code:
Web::Web(int port)
: TNamed("Web", "Web") {
m_http_server = new THttpServer(("http:" + std::to_string(port)).c_str());
m_http_server->Register("/", this);
std::string web_path = "path/to/my/page.html";
m_http_server->SetDefaultPage(web_path.c_str());
m_http_server->RegisterCommand("/CmdFolder/Do", "/Web/->Task(...)");
}
In my Html file:
document.getElementById("btn_start").onclick = function () {
...
cmd_str = `CmdFolder/Do/cmd.json?...`;
JSROOT.NewHttpRequest(cmd_str, "object").send();
};
As definition:
THttpServer *m_http_server;
Many thank you for any kind of help or guidance