NodeJS static web server

Just copy paste the following code in server.js file inside your node app directory.

Then install dependencies using the command: npm install express morgan --save-dev
After installation is completed run: node server and open in your browser the address: http://localhost:3000
Then navigate to your static files eg.
http://localhost:3000/public/index.html, or

Code for a NodeJS App for serving only static files inside ./public folder

var express = require('express');
var morgan = require('morgan');

var hostname = 'localhost';
var port = 3000;

var app = express();

app.use(express.static(__dirname + '/public'));

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