forked from ddennis924/EncoreGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (24 loc) · 815 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
const path = require(`path`);
const express = require('express');
const app = express();
const song = require('./song.js');
const stringSimilarity = require("string-similarity");
const port = process.env.PORT || 3000;
const html = path.join(__dirname, '/root');
app.use(express.static(html));
app.get('/process_get', function (req, res) {
song.add_spotify_playlist(req.query.link, (error, response) => {
if (error) {
res.send(undefined);
} else {
res.send(response);
}
});
})
app.get('/song', function (req, res) {
let matchingScore = stringSimilarity.compareTwoStrings(req.query.ans.toLowerCase(), req.query.guess.toLowerCase());
res.send(matchingScore > 0.75);
})
app.listen(port, () => {
console.log(`Example app listening at ${port}`)
})