-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (43 loc) · 1.38 KB
/
index.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
50
51
52
53
54
55
56
57
const express = require('express');
const path = require('path');
const PORT = process.env.PORT || 5000;
const app = express();
app.use(express.static(path.join(__dirname, './public')));
app.use(express.urlencoded({ extended: true, }));
app.use(express.json());
app.get('/', function (req, res) {
res.send('Hello World!');
});
// app.post('/fullfillment', function (req, res) {
// var intent = "";
// switch(intent){
// case req.body.queryResult.parameters.Hotel:
// const hotelToSearch = req.body.queryResult.parameters.Hotel;
// res.json({
// fullfillmentText: "La keyword in input è " + hotelToSearch,
// source: "fullfillment"
// });
// break;
// case req.body.queryResult.parameters.BeB:
// const bebToSearch = req.body.queryResult.parameters.BeB;
// res.json({
// fullfillmentText: "La keyword in input è " + bebToSearch,
// source: "fullfillment"
// });
// break;
// default:
// res.json({
// fullfillmentText: "caso default"
// });
// }
// });
app.post('/fullfillment', function (req, res) {
const hotelToSearch = req.body.queryResult.parameters.Hotel;
res.json({
fullfillmentText: "La keyword in input è " + hotelToSearch,
source: "fullfillment"
});
});
app.listen(PORT, function () {
console.log('Server in ascolto sulla porta: ' + PORT);
});