Spaces:
Runtime error
Runtime error
const express = require('express'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const app = express(); | |
const PORT = process.env.PORT || 7860; | |
app.use(express.static('public')); | |
app.use('/music', express.static('music')); | |
app.get('/tracks', (req, res) => { | |
fs.readdir('music', (err, files) => { | |
if (err) { | |
return res.sendStatus(500); | |
} | |
res.json(files.filter(file => file.endsWith('.mp3'))); | |
}); | |
}); | |
app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); |