plex-web-downloader/routes/index.js

36 lines
927 B
JavaScript
Raw Normal View History

2015-09-14 12:20:08 -04:00
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
var config = res.locals.config;//require('../config');
2015-09-14 12:20:08 -04:00
var db = config.init_db();
2015-09-15 04:40:12 -04:00
var data = [];
//we do all the basic operations following
2015-09-14 12:20:08 -04:00
db.serialize(function() {
//db.run("CREATE TABLE if not exists user_info (info TEXT)");
//var stmt = db.prepare("INSERT INTO user_info VALUES (?)");
//for (var i = 0; i < 10; i++) {
// stmt.run("Ipsum " + i);
//}
//stmt.finalize();
2015-09-23 17:22:52 -04:00
db.each("SELECT id, name, section_type as type"
2015-09-15 04:40:12 -04:00
+ " FROM library_sections ORDER BY name ASC", function(err, row) {
data.push(row);
2015-09-14 12:20:08 -04:00
},
//after all the operations of the database
2015-09-14 12:20:08 -04:00
function() {
res.render('index', { title: 'List of videos',channels: data, presentation: config.presentation });
2015-09-14 12:20:08 -04:00
});
});
db.close();
});
module.exports = router;