-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 759 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 759 Bytes
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
var express = require('express')
var bodyParser = require('body-parser')
var app = express()
var port = process.env.PORT || 3000
app.use(bodyParser.urlencoded({extended: true}))
app.get('/', function(req, res) {
res.status(200).send('Hello World!')
})
app.post('/username', function(req, res) {
console.log(req.body);
var username = req.body.user_name
var botPayload = {
text: 'Hey, ' + username + '. You must be a hungry, hungry hippo right now! What kind of pizza are you in the mood for?'
}
if (username !== 'slackbot') {
return res.status(200).json(botPayload)
} else {
return res.status(200).end()
}
})
app.listen(port, function() {
console.log('succesfully connected to port', port);
})