исправление роутинга, отображение общей статистики
This commit is contained in:
17
index.js
17
index.js
@ -69,6 +69,11 @@ app.get('/', function(req, res)
|
||||
|
||||
app.use(express.static('build'));
|
||||
|
||||
app.get('*', function(req, res)
|
||||
{
|
||||
res.sendfile(__dirname + '/build/index.html');
|
||||
});
|
||||
|
||||
io.on('connection', function(socket)
|
||||
{
|
||||
function baseRowData(row)
|
||||
@ -96,6 +101,18 @@ io.on('connection', function(socket)
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('statistic', function(callback)
|
||||
{
|
||||
let stats = {};
|
||||
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
||||
stats.torrents = rows[0].tornum;
|
||||
socketMysql.query('SELECT COUNT(*) as filesnum FROM `files`', function (error, rows, fields) {
|
||||
stats.files = rows[0].filesnum;
|
||||
callback(stats)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('torrent', function(hash, options, callback)
|
||||
{
|
||||
if(hash.length != 40)
|
||||
|
Reference in New Issue
Block a user