How can you send an html page with an image from a file via node.js

Viewed 27

I am trying to send an html page with express from the node.js server but for some reason I cannot add an image that is a file This is the code I tried:

const express = require("express");
const app = express();
app.use((req, res) => {
  res.send(`<body><img src='test.png'></body>`)
});

Would appreciate help.

1 Answers

where should the code must look for the image? it needs the relation address of the image in src property. ex: '../../resources/img/test.png'

Related