Answer the question
In order to leave comments, you need to log in
How to load images from html img tags ... img tag in nodejs express?
in the file that the server sends the code "hello world, this by img
html is displayed, but the image is not loaded, so if you go to img/img.jpg the image is loaded
var express =require('express');
var app =express(), server;
app.get('/:page?',function(res,req){
req.sendfile(res.params.page);
})
app.listen(3001);
Answer the question
In order to leave comments, you need to log in
sendfile, emnip, sends a file as an attachment, that is, it forces the browser to download it.
But in general, for statics in express, there is a built-in middleware: expressjs.com/starter/static-files.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question