Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions light.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var addon = require('./build/Release/helloworld');

exports.toggle = function(req, res){
res.send(addon.hello());
}
exports.explain = function(req, res){
res.send('Please use only /toggle/lcd');
// not sure why you were invoking addon.hello() here, but
// you could still do that, no need for the return either
}

24 changes: 8 additions & 16 deletions testnode.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
var addon = require('./build/Release/helloworld');

var http = require("http");

http.createServer(function(request, response) {
if(!('/favicon.ico' == request.url)){
response.writeHead(200, {"Content-Type": "text/plain"});
if('/led/toggle' == request.url){
response.write(addon.hello());
}
else{
response.write("Command not recognized");
}
response.end();
}
}).listen(8888);
var light = require('./light.js');
var express = require('express');
var app = express.createServer();
console.log("Test");
app.use(express.favicon());
app.get('/',light.toString);
app.get('/led/toggle', light.toggle);
app.listen(8888);