-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (27 loc) · 906 Bytes
/
app.js
File metadata and controls
35 lines (27 loc) · 906 Bytes
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
'use strict';
var http = require('http');
var express = require('express');
var IOController = require('./src/controllers/IOController');
var HoverController = require('./src/controllers/HoverController');
var app = express();
var port = 1337;
// taking off and landing command
app.post('/takeoff', function (request, response) {
HoverController.takeOff();
response.status(200).json({ flying: true });
});
app.post('/land', function (request, response) {
HoverController.land();
response.status(200).json({ landed: true });
});
app.post('/blink', function (request, response) {
HoverController.blinkLed();
response.status(200).json({ blink: true });
});
app.get('/healthz', function (request, response) {
response.status(204).json({});
});
var server = http.createServer(app);
IOController.listenCommand(server);
server.listen(port);
console.log('Express listening on port ' + port);