var http = require ('http');
var settings = require('./settings.js')
console.log(settings);
var server = http.createServer();
var msg;
server.on('request', function(req, res){
switch(req.url){
case '/hello':
msg = "Hello world";
break;
case '/about':
msg = "How about you?";
break;
default:
msg = "wrong page";
break;
}
res.writeHead(200, {'Conten-Type': 'text/plain'});
res.write(msg);
res.end();
});
server.listen(settings.port, settings.host);
console.log("server listening ...");
参照:ドットインストール
https://dotinstall.com/lessons/basic_nodejs