How to render pictures with express of node

<!doctype html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    

<%= helloWorld %>

<img src="./a.jpg" alt="" /> </body> </html>
var express = require("express");
var app = express();
// ./views
// app.set("views", path.join("views"));
app.engine("html", require("ejs").renderFile);
app.set("view engine", "html");

/*app.get("/!*", function(req, res, next) {
    console.log(req);
    var referer = req.headers.referer;
    console.log(referer);
    if(referer.indexOf("localhost")===0){
        // res.send("");
        return;
    }else{
        next();  //,next ,
    }
});*/
app.get("/", function(req, res) {
    res.render("index", { helloWorld: "hello,world" });
});
app.listen(3000, function() {
    console.log("app listen at 3000");
});

clipboard.png

Why can"t the picture be rendered, showing 404

Mar.02,2021

there are no pictures processed in your route, so 404, find a plug-in for static resources


express static

Menu