How to Include Static Images in Express JS

preview_player
Показать описание
Ever wonder how to include static images or assets in your Express JS application? Find out how in this quick and easy tutorial.

Resources:
-----------------

Background Thumbnail Photo by rawpixel on Unsplash
Рекомендации по теме
Комментарии
Автор

Can't even describe how much I appreciate this video. Thank you so much!!!

jc
Автор

This was the exact thing which i've been looking for !!!, Thanks mate

ADITYA-kpvb
Автор

I was researching this answer for a LONG TIME... Thank you for your help :D

helenchristine
Автор

Thank you so much for this video! I was struggling with this issue for almost a week... now all works like a charm!

sylvainpeter
Автор

I was tearing my hair out with this!! thanks so much!

Colareiin
Автор

WOW... IT WAS THAT EASY?! I couldn't figure it out so I uploaded my image to Cloudinary and then put that link in my code haha

mannyc
Автор

Thank you sir for resolving my issue...

thilakrajravi
Автор

Hey, I tried adding background image, but its not working, can you help me out or make a video doing same.

Dev-pbdx
Автор

Bro, Thank you soooo much, this helped me a lot,

raguld
Автор

Thanks! for my I realised I needed to do `app.use(express.static(path.join(__dirname, "../public")));` & `app.set("views", path.join(__dirname, "../views"))` with the ../ and it worked perfectly.

cookiigames
Автор

it's still not working for me I have tried all 3 lines and I just get: Cannot GET /a.png 😒😖
hmm I had made a small critical error, my folder was named pubilc instead op public and I only just saw it now

christianhammervig
Автор

I frustrated with this problem thanks a lot sir

Gagan
Автор

What if you have another directory within the views directory? For example: views/campgrounds/index.ejs. In this file it doesn't exept my script file from scripts/index.js :(

gerarddraadjer
Автор

Hi Ian,

Did you change the course contents of Code with Node on Devsprout?

ankitnerlakanti