Seperate public and private file shares

This commit is contained in:
bingus_violet 2024-04-17 08:39:49 -05:00
parent fab571f8be
commit e3eb2130ba

View file

@ -7,6 +7,7 @@ var app = express()
var PORT = process.env.PORT || 8080 var PORT = process.env.PORT || 8080
var directory = process.env.FILES_DIR var directory = process.env.FILES_DIR
var pubDir = path.join(directory, 'public')
function humanFileSize(bytes, si = false, dp = 1) { function humanFileSize(bytes, si = false, dp = 1) {
const thresh = si ? 1000 : 1024; const thresh = si ? 1000 : 1024;
@ -38,6 +39,7 @@ if (!directory) {
const videoFormats = ["mp4", "mkv"] const videoFormats = ["mp4", "mkv"]
app.use(express.static(directory)) app.use(express.static(directory))
app.use(express.static(pubDir))
app.listen(PORT, () => { app.listen(PORT, () => {
console.log("Now listening on PORT: " + PORT) console.log("Now listening on PORT: " + PORT)
@ -93,7 +95,7 @@ app.get("/video/*", (req, res) => {
app.get("/*", (req, res) => { app.get("/*", (req, res) => {
var file = req.params[0] var file = req.params[0]
var absPath = path.join(directory, file) var absPath = path.join(pubDir, file)
if (file != '') { if (file != '') {
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString() var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString()