I need a corporate website with several pages
I've been able to produce that pages using below codes (using ECT template engine):
var http = require('http');
var url = require('url');
var ECT = require('ect');
var renderer = ECT({ root : __dirname + '/views' });
var data = { title : 'blabla' };
var front = renderer.render('front.ect', data);
var aboutus = renderer.render('aboutus.ect', data);
var ourtechnology = renderer.render('ourtechnology.ect', data);
var anypath = renderer.render('anypath.ect', data);
var server=http.createServer(function(req,res){
var pathname=url.parse(req.url).pathname;
switch(pathname){
case '/':
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(front);
break;
case '/aboutus':
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(aboutus);
break;
case '/ourtechnology':
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(ourtechnology);
break;
default:
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(anypath);
break;
}
}).listen(80);
console.log('Server running');
But above codes are hardcoded.
How to make URL dispatching without hardcoding?
(I need to be able to create the page just like posting blog post)
I prefer MySQL for the database, and need guide where to start