Express webpage having problem with static folder

51 Views Asked by At

I am making a webpage with express and express-handlebars and I want to access the images that i have stored in the static folder. I have done all the necessary steps for the static folder but i am still unbale to access the images

const express = require('express')
const path = require('path')
const app = express()
const PORT = 3000

//for handlebars
const exphbs = require('express-handlebars')
app.engine('handlebars', exphbs.engine({
    defaultLayout: 'main',
    layoutsDir: 'views/templates'
}
))
app.set('view engine', 'handlebars')

//for static folder
app.use(express.static('static'))       // problem 

//for route folder
app.use('/', require(path.join(__dirname, "routes/route.js")))


app.listen(PORT, () => {
    console.log(`Running on http://localhost:${PORT}`);
})
0

There are 0 best solutions below