Multiple endpoints
This commit is contained in:
parent
7a3d81ce4a
commit
70181d577e
1 changed files with 10 additions and 2 deletions
12
index.js
12
index.js
|
@ -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)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue