forked from kevinkrzys/VSI-AI-Hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
72 lines (53 loc) · 1.73 KB
/
server.js
File metadata and controls
72 lines (53 loc) · 1.73 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const rosaenlgPug = require('rosaenlg');
const express = require('express')
const app = express();
const port = 4300;
// Add headers
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
next();
});
app.listen(port, () => {
console.log(`Now listening on port ${port}`)
});
app.get('/generateNLG', (req, res) => {
let block = getBlock(req.query.block);
let data = JSON.parse(req.query.data);
let response = rosaenlgPug.renderFile(block, {
language: 'en_US',
data: data
})
console.log(req.query.block);
res.send(response);
});
getBlock = function (block) {
switch (block) {
case "Introduction":
return "introduction.pug";
case "Enterprise Summary":
return "enterprise-summary.pug";
case "Storage by DC":
return "storage-by-dc.pug";
case "Trends - Capacity":
return "capacity.pug";
case "Trends - Performance":
return "performance.pug";
case "Host Summary":
return "host-summary.pug";
case "Pool Alerts":
return "pool-alerts.pug";
case "Provisioning Summary":
return "pro-summary.pug";
case "VMware Summary":
return "vmsummary.pug";
case "Conclusion":
return "conclusion.pug";
case "Signature":
return "signature.pug";
}
}