Multiple endpoints

This commit is contained in:
bingus_violet 2024-10-16 01:00:46 -05:00
parent 7a3d81ce4a
commit 70181d577e

View file

@ -29,11 +29,13 @@ var app = express()
const imgWaitMax = 2 const imgWaitMax = 2
app.get("/cached/*", (req, res) => { app.get("/cached/byURL/*", (req, res) => {
var imgURL = req.originalUrl var imgURL = req.originalUrl
imgURL = imgURL.substring(imgURL.indexOf("/", 2) + 1) imgURL = imgURL.substring(imgURL.indexOf("/", 8) + 1)
var imgData = cachedImages.imgs[imgURL] var imgData = cachedImages.imgs[imgURL]
console.log(imgURL)
var imgWait = 0 var imgWait = 0
function waitForImage() { function waitForImage() {
if (imgWait < imgWaitMax) { if (imgWait < imgWaitMax) {
@ -57,6 +59,12 @@ app.get("/cached/*", (req, res) => {
} }
}) })
app.get("/cached/*", (req, res) => {
var imgURL = req.originalUrl
imgURL = imgURL.substring(imgURL.indexOf("/", 2) + 1)
res.redirect("/cached/byURL/" + imgURL)
})
app.listen(PORT, () => { app.listen(PORT, () => {
console.log("Violet's cache is now listening on port: " + PORT) console.log("Violet's cache is now listening on port: " + PORT)
}) })