2012年1月20日金曜日

node.jsのsampleをcoffeescriptで書いてみる




  • coffeescript
http = require 'http'
httpd = http.createServer (req, res) ->
res.writeHead 200, 'Content-Type': 'text/plain'
res.end 'Hellow World'
httpd.listen 1377, '127.0.0.1'



console.log 'Server running at http://127.0.0.1:1377/'

  • quickrunの結果
var http, httpd;


http = require('http');


httpd = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain'
});
return res.end('Hellow World');
});



httpd.listen(1377, '127.0.0.1');


console.log('Server running at http://127.0.0.1:1377/');

  • nodeで動作確認
node sample.js


[2012-01-20 01:41]


0 件のコメント:

コメントを投稿