forked from segler-alex/radiobrowser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (31 loc) · 930 Bytes
/
server.js
File metadata and controls
36 lines (31 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const port = 4200;
const child_process = require('child_process');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get('/icy', (req, res) => {
const options = {
timeout: 10000,
killSignal: 'SIGKILL'
};
child_process.exec('php icy.php ' + req.query.url, options, function(error, stdout, stderr){
if (stdout !== '') {
if (!stdout.includes('fopen')) {
res.send({'icy-title': stdout});
} else {
res.send({});
}
} else {
res.send({});
}
}, error => {
res.send({});
});
});
process.on('uncaughtException', function (err) {
console.log('Caught exception: ', err);
});
app.listen(port, () => console.log(`Community Radio Browser frontend listening on port ${port}!`));
app.use( express.static(__dirname + '/docs' ) );