Add list to route, allow a list of all images upload
This commit is contained in:
parent
ea770901cb
commit
4fb53bb741
4 changed files with 38 additions and 0 deletions
2
app.js
2
app.js
|
@ -10,6 +10,7 @@ let indexRoute = require("./routes/index");
|
||||||
let uploadRoute = require("./routes/upload");
|
let uploadRoute = require("./routes/upload");
|
||||||
let loginRoute = require("./routes/login");
|
let loginRoute = require("./routes/login");
|
||||||
let imagesRoute = require("./routes/images");
|
let imagesRoute = require("./routes/images");
|
||||||
|
let listRoute = require("./routes/list");
|
||||||
let removeRoute = require("./routes/remove");
|
let removeRoute = require("./routes/remove");
|
||||||
let notFoundRoute = require("./routes/notFound");
|
let notFoundRoute = require("./routes/notFound");
|
||||||
let errorRoute = require("./routes/error");
|
let errorRoute = require("./routes/error");
|
||||||
|
@ -43,6 +44,7 @@ app.use(morgan("dev"))
|
||||||
.use("/upload", uploadRoute)
|
.use("/upload", uploadRoute)
|
||||||
.use("/login", loginRoute)
|
.use("/login", loginRoute)
|
||||||
.use("/images", imagesRoute)
|
.use("/images", imagesRoute)
|
||||||
|
.use("/list", listRoute)
|
||||||
.use("/remove", removeRoute)
|
.use("/remove", removeRoute)
|
||||||
.use(notFoundRoute)
|
.use(notFoundRoute)
|
||||||
.use(errorRoute)
|
.use(errorRoute)
|
||||||
|
|
|
@ -49,3 +49,19 @@ form>div {
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.images {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image {
|
||||||
|
margin: 2em;
|
||||||
|
max-width: 100%;
|
||||||
|
width: auto;
|
||||||
|
max-height: 20em;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
13
routes/list.js
Normal file
13
routes/list.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
let router = require("express").Router();
|
||||||
|
let isAuth = require("../user").isAuth;
|
||||||
|
let fs = require("fs");
|
||||||
|
|
||||||
|
|
||||||
|
router.get("/", isAuth, (req, res, next) => {
|
||||||
|
let images = fs.readdirSync("./images/");
|
||||||
|
res.render("list", {images: images});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
7
views/list.pug
Normal file
7
views/list.pug
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
extend layout
|
||||||
|
block content
|
||||||
|
h1 Images List
|
||||||
|
div.images
|
||||||
|
each image in images
|
||||||
|
img.image(src=`/images/${image}`)
|
||||||
|
|
Loading…
Reference in a new issue