mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-07-08 22:15:09 +00:00
Added cron job, updated webserver, added retry functionality
This commit is contained in:
@@ -30,6 +30,29 @@ app.post('/upload', upload.single('myFile'), async (req, res) => {
|
||||
res.send('File uploaded successfully.');
|
||||
});
|
||||
|
||||
app.get('/sounds', (_req, res) => {
|
||||
const fs = require('fs');
|
||||
const directoryPath = path.join(__dirname, '../sounds');
|
||||
fs.readdir(directoryPath, function (err: any, files: any[]) {
|
||||
if (err) {
|
||||
return console.log(LoggerColors.Red, 'Unable to scan directory: ' + err);
|
||||
}
|
||||
res.send(files);
|
||||
});
|
||||
});
|
||||
|
||||
app.delete('/sounds/:filename', (req, res) => {
|
||||
const fs = require('fs');
|
||||
const directoryPath = path.join(__dirname, '../sounds');
|
||||
const filePath = directoryPath + '/' + req.params.filename;
|
||||
fs.unlink(filePath, (err: any) => {
|
||||
if (err) {
|
||||
return console.log(LoggerColors.Red, 'Unable to delete file: ' + err);
|
||||
}
|
||||
res.send('File deleted successfully.');
|
||||
});
|
||||
});
|
||||
|
||||
app.use(express.static(path.join(__dirname, "web")));
|
||||
|
||||
export function startServer() {
|
||||
@@ -37,4 +60,4 @@ export function startServer() {
|
||||
app.listen(port, () => {
|
||||
console.log(LoggerColors.Cyan,`Add sounds at http://localhost:${port}, or drop in the sounds folder.`);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user