Created
November 28, 2016 18:18
-
-
Save julianh2o/4fb0e422761c23b7098fe5a28e974da7 to your computer and use it in GitHub Desktop.
Voice-activated party mode with a NodeJS Server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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