简体   繁体   中英

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

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM