Hello, Node.js World!

Posted on 2月 26th, 2012 by cx20

Node.js

Node.js は Google の高速 JavaScript エンジン V8 をベースとしたアプリケーションサーバーである。

ソースコード

var http = require("http");
 
http.createServer(function (req, res){
    res.writeHead(200, { "Content-Type": "text/html" });
    res.write("<html>¥n");
    res.write("<body>¥n");
    res.write("Hello, Node.js World!¥n");
    res.write("</body>¥n");
    res.write("</html>¥n");
    res.end();
}).listen(8080);

実行方法

1. モジュールの配置
2. サーバーの起動
   $ node hello.js
3. ブラウザで表示
   http://localhost:8080/hello.js

実行結果

Hello, Node.js World!

Tags:

Categories: JavaScript, Node.js

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

WP-SpamFree by Pole Position Marketing