readme zu markdown
parent
f2cb77dac7
commit
bb7f0ce9f3
140
app.js
140
app.js
|
|
@ -125,43 +125,43 @@ server.get('/getonepic-norefresh', async function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
server.get('/getonepic-old', async function (req, res) {
|
// server.get('/getonepic-old', async function (req, res) {
|
||||||
fs.readdir(sliderpath, function (err, files) {
|
// fs.readdir(sliderpath, function (err, files) {
|
||||||
if (err) {
|
// if (err) {
|
||||||
res.status(500).send("Unable to scan directory: " + err)
|
// res.status(500).send("Unable to scan directory: " + err)
|
||||||
return console.log('Unable to scan directory: ' + err)
|
// return console.log('Unable to scan directory: ' + err)
|
||||||
}
|
// }
|
||||||
console.log(files.length)
|
// console.log(files.length)
|
||||||
let newpictureliststr = ""
|
// let newpictureliststr = ""
|
||||||
files.forEach(function (file) {
|
// files.forEach(function (file) {
|
||||||
newpictureliststr += file
|
// newpictureliststr += file
|
||||||
})
|
// })
|
||||||
console.log(pictureliststr)
|
// console.log(pictureliststr)
|
||||||
console.log(newpictureliststr)
|
// console.log(newpictureliststr)
|
||||||
if (pictureliststr != newpictureliststr) {
|
// if (pictureliststr != newpictureliststr) {
|
||||||
console.log("New files in folder")
|
// console.log("New files in folder")
|
||||||
picturelist = files
|
// picturelist = files
|
||||||
count = files.length
|
// count = files.length
|
||||||
counter = 0
|
// counter = 0
|
||||||
pictureliststr = newpictureliststr
|
// pictureliststr = newpictureliststr
|
||||||
}
|
// }
|
||||||
if (count == 0) {
|
// if (count == 0) {
|
||||||
console.log("Empty directory");
|
// console.log("Empty directory");
|
||||||
return res.status(500).send("Empty directory")
|
// return res.status(500).send("Empty directory")
|
||||||
}
|
// }
|
||||||
if (counter == count) {
|
// if (counter == count) {
|
||||||
console.log("Starting over")
|
// console.log("Starting over")
|
||||||
counter = 0
|
// counter = 0
|
||||||
}
|
// }
|
||||||
let currcounter = counter
|
// let currcounter = counter
|
||||||
counter++
|
// counter++
|
||||||
// res.set("Content-Disposition", 'attachment; filename="picture.png"')
|
// // res.set("Content-Disposition", 'attachment; filename="picture.png"')
|
||||||
// res.set("Content-Disposition", 'inline; filename="picture.png"')
|
// // res.set("Content-Disposition", 'inline; filename="picture.png"')
|
||||||
// res.setHeader('content-type', 'image/jpeg')
|
// // res.setHeader('content-type', 'image/jpeg')
|
||||||
return res.status(200).sendFile(sliderpath + "/" + picturelist[currcounter], { headers: { 'Content-Type': 'image/jpeg' } })
|
// return res.status(200).sendFile(sliderpath + "/" + picturelist[currcounter], { headers: { 'Content-Type': 'image/jpeg' } })
|
||||||
|
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
|
||||||
server.get('/get4pic/:id', async function (req, res) {
|
server.get('/get4pic/:id', async function (req, res) {
|
||||||
let currid = req.params.id
|
let currid = req.params.id
|
||||||
|
|
@ -200,41 +200,41 @@ server.get('/get4pic/:id', async function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
server.get('/getonepic-test', async function (req, res) {
|
// server.get('/getonepic-test', async function (req, res) {
|
||||||
fs.readdir(sliderpath, function (err, files) {
|
// fs.readdir(sliderpath, function (err, files) {
|
||||||
if (err) {
|
// if (err) {
|
||||||
res.status(500).send("Unable to scan directory: " + err)
|
// res.status(500).send("Unable to scan directory: " + err)
|
||||||
return console.log('Unable to scan directory: ' + err)
|
// return console.log('Unable to scan directory: ' + err)
|
||||||
}
|
// }
|
||||||
console.log(files.length)
|
// console.log(files.length)
|
||||||
let newpictureliststr = ""
|
// let newpictureliststr = ""
|
||||||
files.forEach(function (file) {
|
// files.forEach(function (file) {
|
||||||
newpictureliststr += file
|
// newpictureliststr += file
|
||||||
})
|
// })
|
||||||
console.log(pictureliststr)
|
// console.log(pictureliststr)
|
||||||
console.log(newpictureliststr)
|
// console.log(newpictureliststr)
|
||||||
if (pictureliststr != newpictureliststr) {
|
// if (pictureliststr != newpictureliststr) {
|
||||||
console.log("New files in folder")
|
// console.log("New files in folder")
|
||||||
picturelist = files
|
// picturelist = files
|
||||||
count = files.length
|
// count = files.length
|
||||||
counter = 0
|
// counter = 0
|
||||||
pictureliststr = newpictureliststr
|
// pictureliststr = newpictureliststr
|
||||||
}
|
// }
|
||||||
if (count == 0) {
|
// if (count == 0) {
|
||||||
console.log("Empty directory");
|
// console.log("Empty directory");
|
||||||
return res.status(500).send("Empty directory")
|
// return res.status(500).send("Empty directory")
|
||||||
}
|
// }
|
||||||
if (counter == count) {
|
// if (counter == count) {
|
||||||
console.log("Starting over")
|
// console.log("Starting over")
|
||||||
counter = 0
|
// counter = 0
|
||||||
}
|
// }
|
||||||
let currcounter = counter
|
// let currcounter = counter
|
||||||
counter++
|
// counter++
|
||||||
res.set("Content-Disposition", 'attachment; filename="picture.png"')
|
// res.set("Content-Disposition", 'attachment; filename="picture.png"')
|
||||||
return res.status(200).sendFile(sliderpath + "/" + picturelist[currcounter])
|
// return res.status(200).sendFile(sliderpath + "/" + picturelist[currcounter])
|
||||||
|
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue