Add acces to image from url
This commit is contained in:
parent
7d4460b46e
commit
db7eabaa67
1 changed files with 9 additions and 1 deletions
10
app.js
10
app.js
|
@ -80,7 +80,8 @@ app.use(morgan("dev"))
|
|||
fail = true;
|
||||
}
|
||||
res.render("login", {title: "login", fail: fail});
|
||||
}).post("/login", (req, res) => {
|
||||
})
|
||||
.post("/login", (req, res) => {
|
||||
if ("username" in req.body && "password" in req.body) {
|
||||
file = JSON.parse(fs.readFileSync("users.json"));
|
||||
if (req.body.username in file && passwordHash.verify(req.body.password, file[req.body.username])) {
|
||||
|
@ -94,5 +95,12 @@ app.use(morgan("dev"))
|
|||
res.redirect("/login?fail");
|
||||
}
|
||||
})
|
||||
.get("/images/:name", (req, res) => {
|
||||
if ("name" in req.params && fs.existsSync("./images/"+req.params.name)) {
|
||||
res.sendfile("./images/"+req.params.name);
|
||||
} else {
|
||||
res.status(404).send("Image not found :/");
|
||||
}
|
||||
})
|
||||
.listen(8080);
|
||||
|
||||
|
|
Loading…
Reference in a new issue