How to access the picture in NodeJs/Express server?

Good afternoon.

Has the simplest structure of the server:

- src
- - data
- - - images
- - - - 1.jpg
- - - - 2.jpg
- - - - 3.jpg

What you need to do. so when running the server by typing in the address bar for example:

localhost:4006/images/1.jpg

To see the picture?

To download its not necessary, just to display. You must display it on the client.
April 19th 20 at 12:01
1 answer
April 19th 20 at 12:03
Solution
https://expressjs.com/en/starter/static-files.html

with such a folder structure something in the spirit
app.use('/images', express.static(path.join(__dirname, 'src', 'data', 'images')))
So much! - Rosario_Smith commented on April 19th 20 at 12:06

Find more questions by tags Express.js