Custom html and ThttpServer control

I need to develop a web gui to control a stand alone root app on a web server .
I’m trying using THttpServer, JSRoot and custom html code.
I had a look to /tutorials/http/httpControl.C and custom.C but I don’t understand how to control the server using custom html page.

for example I want to connect a button in my custom.htm to execute a function in my server code.
Is there a way to do it?
Thanks in advance

If you want to execute some C++ function from custom.htm, just use ‘exe.json’ requests described here.

On the HTML side code will look like:

 document.getElementById('btn_exe').onclick = function() {
     JSROOT.NewHttpRequest("your_object_name/exe.json?method=DoSomething", 'text', function(res) {
        console.log('Execution result = ', res);
     }).send();
  }

I recommend to use custom.C and custom.htm example only if you want absolutely different page layout compared to normal JSROOT browser for THttpServer. If you just want add button, which is connected to the function call, look to httpcontrol.C example. Here is snapshot of that example:

https://root.cern/js/latest/api.htm#httpcontrol_c_default_page

1 Like

Thank you,
It seems that I start to understand something :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.