To blink the on board LED from a web browser, save the code below as htmlblink.js and from the command line run
# node htmlblink.js
Then point your browser to your device on port 8081
e.g. http://Omega-ABCD:8081
var http = require('http');
var fs = require('fs');
var ledFle = '/sys/class/leds/onion\:amber\:system/brightness';
function led(onOff) {
fs.writeFile( ledFle, onOff, function(err){
if (err) {
return console.log(err);
}
});
}
function handleRequest(req,res) {
if (req.url=='/ledon') {
led(1);
}
if (req.url=='/ledoff') {
led(0);
}
res.writeHead(200, { "Content-Type": "text/html" });
res.write("<h1>LED SWITCH</h1>");
res.write('<a href="/ledon">[ON]</a> | <a href="/ledoff">[OFF]</a> ');
res.end();
}
var server = http.createServer(handleRequest);
server.listen(8081, function(){
console.log("listening for http on port 8081");
});