diff --git a/lib/author.js b/lib/author.js index 950419d..9b30b33 100644 --- a/lib/author.js +++ b/lib/author.js @@ -1,6 +1,7 @@ var db = require('./db'); var template = require('./template.js'); var qs = require('querystring'); +var url = require('url'); exports.home = function(request, response){ db.query(`SELECT * FROM topic`, function(error,topics){ @@ -26,7 +27,7 @@ exports.home = function(request, response){

- +

`, @@ -58,4 +59,48 @@ exports.create_process = function(request, response){ } ) }); +} + +exports.update = function(request, response){ + db.query(`SELECT * FROM topic`, function(error,topics){ + db.query(`SELECT * FROM author`, function(error2,authors){ + var _url = request.url; + var queryData = url.parse(_url, true).query; + db.query(`SELECT * FROM author WHERE id=?`,[queryData.id], function(error3,author){ + var title = 'author'; + var list = template.list(topics); + var html = template.HTML(title, list, + ` + ${template.authorTable(authors)} + +
+

+ +

+

+ +

+

+ +

+

+ +

+
+ `, + `` + ); + response.writeHead(200); + response.end(html); + }); + + }); + }); } \ No newline at end of file diff --git a/lib/template.js b/lib/template.js index 015d750..d71e100 100644 --- a/lib/template.js +++ b/lib/template.js @@ -49,7 +49,7 @@ module.exports = { ${authors[i].name} ${authors[i].profile} - update + update delete ` diff --git a/main.js b/main.js index 0768e1a..b9702cb 100644 --- a/main.js +++ b/main.js @@ -27,6 +27,8 @@ var app = http.createServer(function(request,response){ author.home(request, response); } else if(pathname === '/author/create_process'){ author.create_process(request, response); + } else if(pathname === '/author/update'){ + author.update(request, response); } else { response.writeHead(404); response.end('Not found');