i'm trying setup node.js/express/ejs. know ejs isn't actual html , i'm having hard time displaying simple image. can point me in right direction?
directory structure is:
- myapp/server.js
- myapp/views/index.ejs
- myapp/logo.jpg
right have
// index.ejs <img src = "../logo.jpg" /> am going wrong way? thanks.
static files in express must go inside directory specified in static middleware. commonly ./public/.
for example, in server.js may have this:
app.use( express.static( "public" ) ); each file inside folder accessible root url, work:
<img src="logo.jpg" />
Comments
Post a Comment