Skip to content

Instantly share code, notes, and snippets.

@julianh2o julianh2o/server.js
Created Nov 28, 2016

Embed
What would you like to do?
Voice-activated party mode with a NodeJS Server.
var request = require("request")
var express = require("express")
var app = express()
var LIFX_TOKEN='adbadbadbadbadbabdabdabdbad4adbadbadbadbadbabdbadbabdabdbadbabdb';
app.get("/", function (req, res) {
res.send("Hello World!")
})
app.get("/do", function (req, res) {
var action = req.query.action;
console.log("action received: ",action);
if (action == "party") {
request({uri:"http://192.168.0.107/power/on"});
request({
uri:"https://api.lifx.com/v1/lights/all/state",
method:"PUT",
headers: { "Authorization":"Bearer "+LIFX_TOKEN },
body: JSON.stringify({"color":"purple"}),
});
}
res.send("OK")
})
app.listen(3000, function () {
console.log("Example app listening on port 3000!")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.