-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
56 lines (50 loc) · 1.4 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var http = require('http'),
express = require('express'),
app = express();
app.use(express.logger());
app.use(express.static(__dirname));
app.use(express.directory(__dirname));
app.use(function CORS(req, res, next) {
res.set('Access-Control-Allow-Origin', '*');
res.set('Access-Control-Allow-Headers', 'Content-Type');
next();
});
app.use(app.router);
var server = http.createServer(app);
var port = process.env.PORT || 8080;
server.listen(port);
console.log('Listening on http://localhost:' + port);
var db = [
{
"label" : "Trumpet",
"notes" : [[0],[1],[2],[3],[4],[3],[4],[3],[4],[3],[2],[1],[0],[0],[0],[0]],
"audioClips" : [
"sounds/funkshots Trumpet-1.wav",
"sounds/funkshots Trumpet-3.wav",
"sounds/funkshots Trumpet-5.wav",
"sounds/funkshots Trumpet-7.wav",
"sounds/funkshots Trumpet-8.wav"
]
},
{
"label": "Bass",
"notes": [[1],[1],[1],[1],[0],[0],[0],[0],[3],[3],[3],[3],[0],[0],[0],[0]],
"audioClips" : [
"sounds/funkshots Bass-1.wav",
"sounds/funkshots Bass-3.wav",
"sounds/funkshots Bass-5.wav",
"sounds/funkshots Bass-7.wav",
"sounds/funkshots Bass-8.wav"
]
}
];
app.options('/data', function(req, res) {
res.send(200);
});
app.post('/data', express.json(), express.urlencoded(), function(req, res) {
db = req.body;
res.send(200);
});
app.get('/data', function(req, res) {
res.json(db);
});