You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
545 B
21 lines
545 B
const express = require('express'); |
|
const bodyParser = require('body-parser'); |
|
|
|
const app = express(); |
|
const port = process.env.PORT || 5000; |
|
|
|
app.use(bodyParser.json()); |
|
app.use(bodyParser.urlencoded({ extended: true })); |
|
|
|
app.get('/api/hello', (req, res) => { |
|
res.send({ express: 'Hello From Express' }); |
|
}); |
|
|
|
app.post('/api/world', (req, res) => { |
|
console.log(req.body); |
|
res.send( |
|
`I received your POST request. This is what you sent me: ${req.body.post}`, |
|
); |
|
}); |
|
|
|
app.listen(port, () => console.log(`Listening on port ${port}`)); |