public static in nodejs code example

Example 1: express img folder

app.use(express.static('public'))

Example 2: access to static file nodejs

app.use(express.static(__dirname + '/public'));
<link rel="stylesheet" type="text/css" href="css/style.css" />

Example 3: app.use public

app.use(express.static('public'))
app.use(express.static('files'))

Example 4: use static with expres

app.use(express.static('directoryName'))
#store the files in the directory as if you were making a website without express

Tags:

Misc Example