image_node/routes/images.js

16 lines
286 B
JavaScript
Raw Normal View History

2020-04-26 20:12:50 +02:00
let router = require("express").Router();
let fs = require("fs");
router.get("/:name", (req, res, next) => {
if ("name" in req.params && fs.existsSync("./images/"+req.params.name)) {
res.sendfile("./images/"+req.params.name);
} else {
next();
}
});
module.exports = router;