-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
53 lines (45 loc) · 1.32 KB
/
server.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const app = require('express')();
const http = require('http').Server(app);
const fs = require('fs');
const exec = require('child_process').exec;
app.get('/nepovednik', function(req, res) {
res.sendFile(__dirname + '/izberi.html');
});
app.get('/nepovednik/apple/nepovid/:id', function (req, res) {
let st = parseInt(req.params.id);
if (st < 1 || st > 1000) {
res.status(404);
}
let nejm = 'nepovedi/' + st + '.mp4';
if (fs.existsSync(nejm)) {
res.sendFile(__dirname + '/' + nejm);
}
});
app.get('/nepovednik/nepovid/:id', function (req, res) {
let st = parseInt(req.params.id);
if (st < 1 || st > 1000) {
res.status(404);
}
let nejm = 'nepovedi/' + st + '.webm';
if (fs.existsSync(nejm)) {
res.sendFile(__dirname + '/' + nejm);
}
});
app.get('/nepovednik/nepoved/:ime', function (req, res) {
let st = parseInt(req.params.ime);
if (st < 1 || st > 1000) {
res.status(404);
}
let nejm = 'nepovedi/' + st + '.webm';
if (fs.existsSync(nejm)) {
res.send('/nepovid/' + st);
} else if (fs.existsSync('nepovedi/najava' + st)) {
res.send("cakaj");
} else {
exec('node nepovednik.js ' + st);
res.send("zacetek");
}
});
http.listen(5000, function() {
console.log('listening on *:5000');
});