-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
39 lines (30 loc) · 1.09 KB
/
index.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
var path = require('path');
var express = require('express');
var coffeeMid = require('coffee-middleware');
var dronestream = require('dronestream');
var client = require('./lib/drone');
var config = require('./config/config');
var app = express();
var routes = require('./lib/routes/');
var port = config.webServerPort || 3000;
var streamPort = /*config.streamPort ||*/ 3001; // hard coded, sorry
var publicDir = path.join(__dirname, 'public');
dronestream.listen(streamPort, {tcpVideoStream: client.getVideoStream()});
app.configure(function() {
app.use(coffeeMid({
src: publicDir
}));
app.use(express.static(publicDir));
app.use(express.json());
app.use(express.urlencoded());
});
app.post('/voice-command', routes.voiceCommand.submit);
app.get('/camera/:id', routes.pngStream.get);
app.get('/vendor/dronestream.js', function(req, res) {
res.sendfile(path.join(
'node_modules', 'dronestream', 'dist', 'nodecopter-client.js'
));
});
app.listen(port, function() {
console.log('Web server is now listening on port: ' + port);
});