Skip to content

Instantly share code, notes, and snippets.

@mooyoul
Last active January 23, 2017 20:05
Show Gist options
  • Save mooyoul/9c9b29896aa048b68ec04ee5d37f9f8b to your computer and use it in GitHub Desktop.
Save mooyoul/9c9b29896aa048b68ec04ee5d37f9f8b to your computer and use it in GitHub Desktop.
Nexmo Simple Demo
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use((req, res, next) => {
console.log('Got request, %s %s', req.method, req.url, req.ip, req.headers);
next();
});
app.route('/init')
.get((req, res) => {
res.send([{
"action": "talk",
"text": "Hello world! An-nyeong-ha-se-yo. This is the Nexmo Voice API ip-ni-da"
}]);
});
app.route('/events')
.get((req, res) => {
console.log('got event get request');
console.log(req.url, req.query);
res.sendStatus(204);
})
.post((req, res) => {
console.log('got event post request');
console.log(req.url, req.query, req.body);
res.sendStatus(204);
});
app.listen(9000, () => {
console.log('Server started at port 9000...');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment