Cannot access images in folder Node JS

nodejs

#1

Hi,

I am trying to access images which I have saved in the public folder (see folder structure below) to use as background images in my app.css file, but they are not appearing when I run node.js. Can anyone tell me where I’m going wrong please? I’m very new to this :slight_smile:

From app.js file:
app.use(express.static(__dirname + ‘/public’));

from app.css file:
#a5 {
background: url(“img/wsh5.jpg”);
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}

27%20PM


#2

Also, if anyone can tell me how to properly post code when I’m asking a question that would be very helpful also :smile: Thanks!