diff --git a/CloudServer/server.js b/CloudServer/server.js index e5fa564..ccf795b 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -82,6 +82,18 @@ app.use((req, res, next) => { else if (req.path.endsWith('.ts')) res.type('video/mp2t'); next(); }); + +function sendListFile(res) { + if (!fs.existsSync(listFilePath)) { + return res.status(404).send('list.txt not found'); + } + res.type('text/plain; charset=utf-8'); + res.send(fs.readFileSync(listFilePath, 'utf8')); +} + +app.get('/list.txt', (req, res) => sendListFile(res)); +app.get('/uploads/list.txt', (req, res) => sendListFile(res)); + app.use(express.static(path.join(__dirname, 'public'))); app.set('view engine', 'ejs'); diff --git a/station_broadcast.lua b/station_broadcast.lua index e94ff54..e0df46b 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1012,7 +1012,10 @@ end function Network.syncFiles() -- Sync only config file (list.txt) periodically while true do - local resp = http.get(CONFIG.API_URL .. "/uploads/list.txt") + local resp = http.get(CONFIG.API_URL .. "/list.txt") + if not resp then + resp = http.get(CONFIG.API_URL .. "/uploads/list.txt") + end if resp then local content = resp.readAll() resp.close()