-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (34 loc) · 1.19 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
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var textmatcher = require("./textmatcher.js");
var app = express();
app.use(cors());
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '10mb' }));
//expects object {input: string, algodata: algorithmdata}
app.route('/api/matcher').post((req, res) => {
console.log('got post matching request!');
var result = textmatcher(req.body, false, false);
res.status(201).send(result);
});
app.route('/api/matcher/rake').post((req, res) => {
console.log('got post matching request!');
var result = textmatcher(req.body, true, false);
res.status(201).send(result);
});
app.route('/api/matcher/openai').post((req, res) => {
console.log('got post matching request!');
textmatcher(req.body, false, true).then(result => {
res.status(201).send(result);
});
});
app.route('/api/matcher/rake/openai').post((req, res) => {
console.log('got post matching request!');
textmatcher(req.body, true, true).then(result => {
res.status(201).send(result);
});
});
app.listen(1985, () => {
console.log('Server started!');
});