-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
45 lines (29 loc) · 928 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var utils = require('./lib/utilities'),
express = require('express'),
_ = require('underscore'),
app = express();
app.get('/', function (req, res) {
});
app.get('/party/:status', function (req, res) {
var outlets = {
'ropeLight': 'a1',
'stopLight' : 'a2',
'martiniGlass' : 'a3'
};
var status = req.params.status;
_.each(outlets, function(channel) {
utils.toggle(channel,status);
});
res.send('\nParty Mode ' + status + '!\n\n')
});
app.get('/:channel/:status', function (req, res) {
var channel = req.params.channel,
status = req.params.status;
utils.toggle(channel,status);
res.send('\nSwitched ' + channel + ' to ' + status + '\n\n')
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('listening at http://%s:%s', host, port);
});