-
Notifications
You must be signed in to change notification settings - Fork 0
/
voicereply.js
39 lines (30 loc) · 959 Bytes
/
voicereply.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
var express = require('express');
var bodyParser = require('body-parser')
var fs = require('fs');
var app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use('/public', express.static(__dirname + '/public'));
app.all('/*', function(req, res, next){
console.log("URL:: " + req.path);
console.log("Method:: " + req.method);
next();
});
app.get('/api/voice', function (req, res, next) {
res.status(200).send(JSON.stringify({"status" : "success"}));
next();
});
app.post('/api/getanswer', function (req, res, next) {
q = req.body.question;
console.log(q);
/* XXX get reply from Google's AI bot */
res.status(200).send(JSON.stringify({resp: "I am good"}));
next();
});
app.get('/*', function(req, res, next){
res.sendFile(__dirname + '/public/speech_AI.html');
});
var port = 2300;
app.listen(port, function() {
console.log('server listening on port ' + port);
});