Skip to content

Instantly share code, notes, and snippets.

@samsonl
Created October 24, 2018 01:48
Show Gist options
  • Save samsonl/df4b6080f093648932a2559b62b2b5da to your computer and use it in GitHub Desktop.
Save samsonl/df4b6080f093648932a2559b62b2b5da to your computer and use it in GitHub Desktop.
// content of index.js
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
console.log(request.url)
response.end('Hello Node.js Server!')
}
const server = http.createServer(requestHandler)
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})
You can start it with:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment