1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.js : Basic Level - サーバー設定を実装してみる

Last updated at Posted at 2018-06-03

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

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?