1var express = require('express');
2var app = express();
3var path = require('path');
4
5//app.use(express.static(__dirname)); // Current directory is root
6app.use(express.static(path.join(__dirname, 'public'))); // "public" off of current is root
7
8app.listen(80);
9console.log('Listening on port 80');
1// projectDirectory/src/index.js
2const path = require('path')
3const publicDirectoryPath = path.join(__dirname, '../public')
4app.use(express.static(publicDirectoryPath))
5
6// projectDirectory/public -> create index.html
7// localhost:3000/index.html -> Here you go..
8
9
1// dependencies
2const path = require('path');
3
4// set static folder
5app.set(express.static(path.join(__dirname, 'public')));