Last active
July 20, 2018 07:22
-
-
Save ThunderWiring/a337daec7405e776e83e9c309705e459 to your computer and use it in GitHub Desktop.
creating a simple HTTP server using NodeJs and ExpressJs which handles a POST request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require("body-parser"); | |
const port = 3000; | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
const server = app.listen(port, '<ip_address>'); | |
app.post('/post-request-url', (request, response) => { | |
response.send('response from server to the post request!'); | |
}) | |
server.on('listening', (error) => { | |
if (error) { | |
console.error('error ancountered: ' + error); | |
} else { | |
console.log('Express server started on port %s at %s', | |
server.address().port, | |
server.address().address); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment