-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
42 lines (30 loc) · 861 Bytes
/
server.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
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();
app.set('port', process.env.PORT || 3000);
app.use(express.static(path.join(__dirname, 'client')));
var http = require('http');
//TODO generic /led/* path and just 'apply' / eval the cmd
app.get('/candy', function(req, res){
res.send('candy ');
if(app.candyMachine){
app.candyMachine.dispense();
}
});
app.get('/open', function(req, res){
res.send('candy open');
if(app.candyMachine){
app.candyMachine.open();
}
});
app.get('/close', function(req, res){
res.send('candy close');
if(app.candyMachine){
app.candyMachine.close();
}
});
var server = app.listen(3001, function() {
console.log('Listening on port %d', server.address().port);
});
module.exports = app;