From 377c48a43060a5973f0768c3b6b1cc784e30b26d Mon Sep 17 00:00:00 2001 From: WEBER Antoine Date: Wed, 23 Sep 2015 23:39:18 +0200 Subject: [PATCH] utilisation de request params id --- routes/show.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/routes/show.js b/routes/show.js index 21bfcc7..0cb20a8 100644 --- a/routes/show.js +++ b/routes/show.js @@ -1,30 +1,19 @@ var express = require('express'); var router = express.Router(); -function btoa(string){ - return new Buffer(string).toString('base64'); -} - -function atob(string){ - return new Buffer(string, 'base64').toString('ascii'); -} - /* GET home page. */ router.get('/:id', function(req, res, next) { var config = require('../config'); var db = config.init_db(); var data = []; - var id = /*atob(*/req.params.id/*)*/; - console.log(id); - //on fais toute les opération de base a la suite db.serialize(function() { db.each("SELECT i.id as id, i.title as title, t.hints as hints, p.file as file, i.duration as second, t.size as size, i.year as year" + " FROM media_items t, metadata_items i, media_parts p " + " WHERE t.id=p.media_item_id AND t.metadata_item_id = i.id AND t.hints LIKE '%show=?%' " - ,id, function(err, row) { + ,req.params.id, function(err, row) { console.log(err); console.log(row); //découpage des hints @@ -53,10 +42,14 @@ router.get('/:id', function(req, res, next) { }, //aprés toute les opération de la base function() { - res.render('channel', { title: 'Episode de :'+id,channel:{ - 'name': 'Episode de :'+id, - 'type': 2 - },videos: data }); + res.render('channel',{ + title: 'Episode de '+req.params.id, + channel: { + 'name': 'Episode de '+req.params.id, + 'type': 2 + }, + videos: data + }); });