Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http = require('http')
- const app = new http.Server()
- app.on('request', (req, res) => {
- let method = req.method.toLowerCase()
- if (req.method.toLowerCase() == 'post') {
- // container to hold the incoming data
- var data = ""
- req.on('data', (chunk) => {
- // append as data keeps coming in
- data += chunk.toString()
- })
- req.on('end', () => {
- // all the data has been received
- console.log(data)
- res.writeHead(200, { 'Content-Type': 'text/plain' })
- res.write('got it')
- res.end('\n')
- })
- }
- })
- app.listen(10588)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement