Answer the question
In order to leave comments, you need to log in
How to pass a jpg image from Node.js to the browser?
How to pass a jpg image from Node.js to the browser and display it on the page?
Answer the question
In order to leave comments, you need to log in
require("http").createServer((req, res) => {
if (req.url === "/") {
res.statusCode = 200;
res.setHeader("Content-Type", "image/jpeg");
require("fs").readFile("./image.jpg", (err, image) => {
res.end(image);
});
}
}).listen(3000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question