Skip to content

Instantly share code, notes, and snippets.

@bndynet
Last active April 4, 2018 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bndynet/667644b987a797eacc5ac506df9fd835 to your computer and use it in GitHub Desktop.
Save bndynet/667644b987a797eacc5ac506df9fd835 to your computer and use it in GitHub Desktop.
Hello World

Hello World for All Programming Languages

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\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

with express

npm install express --save

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment