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: Node.js
Categories: JavaScript, Node.js