Skip to content

Instantly share code, notes, and snippets.

@crcastle
Last active January 24, 2018 21:23
Show Gist options
  • Save crcastle/d99a2213d249ccf6d5c5b53912db83eb to your computer and use it in GitHub Desktop.
Save crcastle/d99a2213d249ccf6d5c5b53912db83eb to your computer and use it in GitHub Desktop.
Simplest Node.js Web Server
const http = require('http')
const PORT = 3000
const requestHandler = (request, response) => {
response.end('Hello World!')
}
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}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment