forked from arcturial/clickatell-node
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcallback.js
44 lines (27 loc) · 925 Bytes
/
callback.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
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const http = require('http')
const port = 80
const server = http.createServer(app)
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(express.json()); // to support JSON-encoded bodies
app.use(express.urlencoded()); // to support URL-encoded bodies
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`);
app.get('/', function (req, res) {
res.send('This is an example route.')
})
app.post('/sms', function (req, res) {
const body = req.body
console.log(body);
res.set('Content-Type', 'text/plain')
res.send(`You sent: ${body}`)
})
})