-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (41 loc) · 1.31 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
const express = require('express');
const getResponse = require('./getResponse');
const server = express();
server.use(express.json());
server.use(express.urlencoded({extended: true}));
server.use('/', express.static('site'));
server.post('/api/', (req, res) => {
const input = req.body.input;
console.log('input: ', input);
const output = getResponse(input);
console.log('output: ', output);
res.json({output: output});
});
server.get('/api/idea', (req, res) => {
const idea = getResponse.getIdea();
res.json({idea: idea});
});
server.post('/api/sentiment', (req, res) => {
const input = req.body.input;
console.log('input: ', input);
const sentiment = getResponse.analyzeSentiment(input);
console.log('sentiment: ', sentiment);
res.json({sentiment: sentiment});
});
server.post('/api/stem', (req, res) => {
const input = req.body.input;
console.log('input: ', input);
const stemmed = getResponse.stemInput(input);
console.log('stemmed: ', stemmed);
res.json({stemmed: stemmed});
});
server.post('/api/pos', (req, res) => {
const input = req.body.input;
console.log('input: ', input);
const pos = getResponse.posTagger(input);
console.log('pos: ', pos);
res.json(pos);
});
server.listen(4000, () => {
console.log('server running...');
});