You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
801 B
33 lines
801 B
const express = require('express'); |
|
const app = express(); |
|
const path = require('path'); |
|
const fs = require('fs'); |
|
|
|
const port = 8000 |
|
|
|
const assetsDir = path.join(__dirname, 'assets'); |
|
|
|
app.use(express.static(path.join(__dirname))); |
|
|
|
app.get('/', (req, res) => { |
|
res.sendFile(path.join(__dirname, 'index.html')); |
|
}); |
|
|
|
app.get('/api/videos', (req, res) => { |
|
fs.readdir(assetsDir, (err, files) => { |
|
if (err) { |
|
console.error('Error reading directory:', err); |
|
res.status(500).send('Internal Server Error'); |
|
return; |
|
} |
|
|
|
const webmFiles = files.filter(file => file.endsWith('.webm')); |
|
const videoFiles = webmFiles.map(file => ({ src: `assets/${file}` })); |
|
|
|
res.json(videoFiles); |
|
}); |
|
}); |
|
|
|
app.listen(port, () => { |
|
console.log('Server started on port', port); |
|
});
|
|
|