What you want to do is follow any nodejs tutorial you can find. Here are ~25 of them: https://codeburst.io/25-node-js-tutorials-1db3b1da0260
The code below should get you started though. Ssh to your rPI and use the following:
This will install express, which is a wrapper around many of node’s basic http commands (https://expressjs.com/):
npm install express --save
nano ~/app.js (this will open your editor)
In your editor, type the following:
var exec = require('child_process').exec;
var express = require('express'),
app = express(),
port = 8001;
app.get("/cmd/display/:state", (req, res, next) => {
exec('vcgencmd display_power ' + req.params['state'], function(error, stdout, stderr) {
console.log('stdout: ' + stdout);
res.json('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
res.json('exec error: ' + error);
}
});
});
app.listen(port);
console.log('Command API server started on: ' + port);
Save that file and then in the command line type: node app.js
You should see a console line that states: ‘Command API server started on: 8001’. From there, on your desktop, open a browser to http://[your_pi_ipaddress]:8001/cmd/display/0 to turn off the display and http://[your_pi_ipaddress]:8001/cmd/display/1 to turn it back on.
This is a VERY basic example, and you might need to tweak the ‘vcgencmd’ command (if it’s not in your path or whatnot), but should start you on your way to what you want to do with your rPi.