Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = require('express')();
- var http = require('http').Server(app);
- var io = require('socket.io')(http);
- var request = require('request');
- app.get('/', function(req, res){
- res.sendFile(__dirname + '/index.html');
- });
- io.on('connection', function(socket){
- console.log("connected");
- });
- io.on('color cycle', function(){
- console.log("Button Pressed");
- request({
- url: "xxxxxxxxxx",
- method: "POST",
- json: {"value": "1"},
- headers: {
- "Content-type": "application/json",
- "X-AIO-KEY": "xxxxxxxxxxx"
- },
- }, function (err, resp, body) {
- if ( !err && body) {
- console.log("Body: "+body);
- } else if (err) {
- console.log("Error: "+err);
- }
- console.log("Response: "+resp);
- })
- })
- http.listen(8080, function(){
- console.log('listening on *:8080');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement