-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (33 loc) · 1.06 KB
/
Copy pathserver.js
File metadata and controls
38 lines (33 loc) · 1.06 KB
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
var express = require("express"),
app = express(),
bodyParser = require('body-parser'),
sqlite = require('sqlite3'),
db = new sqlite.Database('test.db'),
port = 4567;
app.get("/", function (req, res) {
res.redirect("/index.html");
});
app.get('/get_words', function(req, res) {
db.get("SELECT phrase_counts FROM music where artist_name=?", [req.query.artist], function(err, row) {
// row.counts = row.counts.replace(/'/g, '"');
// console.log(row.counts.indexOf("'"));
// console.log(row.counts.indexOf("\'"));
// console.log(row);
if (!row) {
res.send(null);
return;
}
//lol fix later...
db.get("SELECT phrase_counts FROM music where artist_name=?", [req.query.artist], function(err, row1) {
console.log(row.phrase_counts);
res.send({phrases: row.phrase_counts});
});
});
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static(__dirname));
console.log("Simple static server listening at http://localhost:" + port);
app.listen(port);