Azure Kubernetes Service - Part 2 - Creating an AKS Cluster

NodeJS - Getting Started with Hello World

We use Node.js to build scalable and efficient service-side applications.    A real good place to start is with the official Node.js website (https://nodejs.org).   This post, like so many of my others, serves me as a quick place to get started as I create Node applications so infrequently.

1. Install Node.js
2. Setup new project - "npm init"


3. Create new "*.js" file for your application code.   This sample creates a simple Hello World application...  The script will setup a basic HTTP server that listens on localhost (127.0.0.1) at port 3000.   "Hello World!" will be displayed when you access your browser at http://127.0.0.1:3000.

    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}/`);
    });


4.  Start the Server..... "node server.js" where the name of the JavaScript file is the name of the file that contains the code.   You should notes that the node server is currently running.




 

5.  Start your browser and go to http://127.0.0.1:3000.   That is it!!!  So easy, I should remember how to do it every time....