Skip to content

Instantly share code, notes, and snippets.

@rasolofonirina
Last active March 25, 2022 12:45
Show Gist options
  • Save rasolofonirina/ee27b4016f806941a5fafa322f31284a to your computer and use it in GitHub Desktop.
Save rasolofonirina/ee27b4016f806941a5fafa322f31284a to your computer and use it in GitHub Desktop.
Hello world with Node.js
const http = require('http')
const hostname = '127.0.0.1'
const port = 3000
const server = http.createServer((req, res) => {
res.statusCode = 200
res.setHeader('Content-Type', 'text/plain')
res.end('Hello World')
})
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment