Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how express serve public folder

// projectDirectory/src/index.js
const path = require('path')
const publicDirectoryPath = path.join(__dirname, '../public')
app.use(express.static(publicDirectoryPath))

// projectDirectory/public -> create index.html
// localhost:3000/index.html -> Here you go..

Comment

static folder express

// dependencies
const path = require('path');

// set static folder
app.set(express.static(path.join(__dirname, 'public')));
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs how to send html 
Javascript :: preventdefault not working react 
Javascript :: get value of radio button javascript 
Javascript :: jquery force page to reload on viewport resize 
Javascript :: javascript find object in array 
Javascript :: average function for javascript 
Javascript :: boolean constructor js 
Javascript :: ERESOLVE unable to resolve dependency tree npm ERR npm ERR! Found: @angular/core@5.0.3 npm ERR! node_modules/@angular/core 
Javascript :: turn Iterator into array JS 
Javascript :: fetch method in js 
Javascript :: change color js 
Javascript :: express req body undefined 
Javascript :: javascript log html element as dom object 
Javascript :: avoid no-param-reassign when setting a property 
Javascript :: object deep copy 
Javascript :: preload javascript 
Javascript :: how to get element by id 
Javascript :: react public pic 
Javascript :: axios react 
Javascript :: difference between indexof and search in javascript 
Javascript :: process.stdin.on("data", function (input) { _input += input; }); 
Javascript :: data not write in file node js 
Javascript :: How to make blinking/flashing text with jQuery 
Javascript :: add query parameter to url react router v6 
Javascript :: redis nodejs 
Javascript :: embed video by javascript 
Javascript :: javascript password hashing 
Javascript :: json objects 
Javascript :: selected angular select 
Javascript :: unique element in array 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =