This is most likely a repeated question.
The closest I got to an answer was here: execute a Nodejs script from an html page?
Yet, I still can't understand.
So here's the situation:
I have an express server setup with the following files:
- Express App
server.js index.html
and right now I want the html folder to have a button, that calls a function set in the node.js file.
I am using an express server to present a website, that present a button saying " Power Off", I want this button to be able to execute an action on my server computer, that action being a terminal command to power it off.
I wanted to know how could I make said button, written in HTML, hosted on the server but presented to the client, to interact with the server.js file hosted on the server, which would have a function set to execute said command.
<script src="myscripts.js"></script><script>tagnodeperson but the OP could also mean "is there a way to emit server side methods, inline html" just as one would in other "frameworks" like Pph, ASP..Net etc. So something like<h1><%=foo()%></h1>would be how I'd do it in ASP/.Net for example ("calling aC#orVBfoo()function") in HTML (view)...skipping "extra" Ajax calls (it's rendered without extra client-side call). I'd be interested in learning too....