-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (25 loc) · 701 Bytes
/
Copy pathserver.js
File metadata and controls
33 lines (25 loc) · 701 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
const express = require('express');
const app = express();
const port = 3000;
const scatter = require('./scatter');
const index = require('./index.js');
app.use(express.static(__dirname));
app.get('/', (request, response) => {
response.send(scatter);
});
app.get('/scatter', (request, response) => {
console.log('-----plotting scatterplot-----');
index.getSentiment()
.then(sentiment => {
response.send(sentiment);
})
.catch((err) => {
response.status(500).send({ error: err.message });
});
});
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err);
}
console.log(`server is listening on ${port}`);
});