-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
omatoro
authored and
omatoro
committed
Jul 15, 2013
1 parent
788511b
commit d783275
Showing
132 changed files
with
11,574 additions
and
10,226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,10 +1,10 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
|
|
||
var http = require("http"); | var http = require("http"); | ||
http.createServer(function (req, res) { | http.createServer(function (req, res) { | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | res.writeHead(200, {"Content-Type": "text/plain"}); | ||
res.end("hello, world!\n"); | res.end("hello, world!\n"); | ||
}).listen(1337, "localhost"); | }).listen(1337, "localhost"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
/* | |||
* hello, world | |||
* IPなど設定:http://testcording.com/?p=1164 | |||
*/ | |||
|
|||
var http = require("http"); | |||
http.createServer(function (req, res) { | |||
res.writeHead(200, {"Content-Type": "text/plain"}); | |||
res.end("hello, world!\n"); | |||
}).listen(1337, "localhost", function () { | |||
console.log("Server running at http://127.0.0.1:1337/"); | |||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,13 +1,13 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
|
|
||
var http = require("http"); | var http = require("http"); | ||
http.createServer(function (req, res) { | http.createServer(function (req, res) { | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | res.writeHead(200, {"Content-Type": "text/plain"}); | ||
res.end("hello, world!\n"); | res.end("hello, world!\n"); | ||
}).listen(1337, "localhost", function () { | }).listen(1337, "localhost", function () { | ||
console.log("Server running at http://127.0.0.1:1337/"); | console.log("Server running at http://127.0.0.1:1337/"); | ||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | console.log("サーバを終了する際は[ctrl + c]を押してください"); | ||
}); | }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
/* | |||
* hello, world | |||
* IPなど設定:http://testcording.com/?p=1164 | |||
*/ | |||
|
|||
var IP_ADDRESS = "localhost"; | |||
var PORT = 1337; | |||
|
|||
var http = require("http"); | |||
http.createServer(function (req, res) { | |||
res.writeHead(200, {"Content-Type": "text/plain"}); | |||
res.end("hello, world!\n"); | |||
}).listen(PORT, IP_ADDRESS, function () { | |||
console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | |||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,16 +1,16 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
|
|
||
var IP_ADDRESS = "localhost"; | var IP_ADDRESS = "localhost"; | ||
var PORT = 1337; | var PORT = 1337; | ||
|
|
||
var http = require("http"); | var http = require("http"); | ||
http.createServer(function (req, res) { | http.createServer(function (req, res) { | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | res.writeHead(200, {"Content-Type": "text/plain"}); | ||
res.end("hello, world!\n"); | res.end("hello, world!\n"); | ||
}).listen(PORT, IP_ADDRESS, function () { | }).listen(PORT, IP_ADDRESS, function () { | ||
console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | ||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | console.log("サーバを終了する際は[ctrl + c]を押してください"); | ||
}); | }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,30 +1,30 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
/* | /* | ||
* パラメータ | * パラメータ | ||
*/ | */ | ||
var IP_ADDRESS = "localhost"; | var IP_ADDRESS = "localhost"; | ||
var PORT = 1337; | var PORT = 1337; | ||
|
|
||
/* | /* | ||
* モジュール読み込み | * モジュール読み込み | ||
*/ | */ | ||
var http = require("http"); | var http = require("http"); | ||
|
|
||
/* | /* | ||
* サーバの作成 | * サーバの作成 | ||
*/ | */ | ||
http.createServer(function (req, res) { | http.createServer(function (req, res) { | ||
// ヘッダーの送信 送信するデータのタイプはtext/plain | // ヘッダーの送信 送信するデータのタイプはtext/plain | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | res.writeHead(200, {"Content-Type": "text/plain"}); | ||
// 中身の文字列を送信 | // 中身の文字列を送信 | ||
res.end("hello, world!\n"); | res.end("hello, world!\n"); | ||
}).listen(PORT, IP_ADDRESS, function () { | }).listen(PORT, IP_ADDRESS, function () { | ||
/* | /* | ||
* サーバ起動時に表示するログ(起動したことが分かりやすい) | * サーバ起動時に表示するログ(起動したことが分かりやすい) | ||
*/ | */ | ||
console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | ||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | console.log("サーバを終了する際は[ctrl + c]を押してください"); | ||
}); | }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,32 +1,32 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
/* | /* | ||
* パラメータ | * パラメータ | ||
*/ | */ | ||
var IP_ADDRESS = "localhost"; | var IP_ADDRESS = "localhost"; | ||
var PORT = 1337; | var PORT = 1337; | ||
|
|
||
/* | /* | ||
* モジュール読み込み | * モジュール読み込み | ||
*/ | */ | ||
var http = require("http"); | var http = require("http"); | ||
|
|
||
/* | /* | ||
* サーバの作成 | * サーバの作成 | ||
*/ | */ | ||
http.createServer(function (req, res) { | http.createServer(function (req, res) { | ||
// リクエストされたURLをログに表示(ブラウザからアクセスされるたびにコンソールへ出力する) | // リクエストされたURLをログに表示(ブラウザからアクセスされるたびにコンソールへ出力する) | ||
console.log(req.url); | console.log(req.url); | ||
// ヘッダーの送信 送信するデータのタイプはtext/plain | // ヘッダーの送信 送信するデータのタイプはtext/plain | ||
res.writeHead(200, {"Content-Type": "text/plain"}); | res.writeHead(200, {"Content-Type": "text/plain"}); | ||
// 中身の文字列を送信 | // 中身の文字列を送信 | ||
res.end("hello, world! : URL " + req.url); | res.end("hello, world! : URL " + req.url); | ||
}).listen(PORT, IP_ADDRESS, function () { | }).listen(PORT, IP_ADDRESS, function () { | ||
/* | /* | ||
* サーバ起動時に表示するログ(起動したことが分かりやすい) | * サーバ起動時に表示するログ(起動したことが分かりやすい) | ||
*/ | */ | ||
console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | ||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | console.log("サーバを終了する際は[ctrl + c]を押してください"); | ||
}); | }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
/* | |||
* hello, world | |||
* IPなど設定:http://testcording.com/?p=1164 | |||
*/ | |||
/* | |||
* パラメータ | |||
*/ | |||
var IP_ADDRESS = "localhost"; | |||
var PORT = 1337; | |||
|
|||
/* | |||
* モジュール読み込み | |||
*/ | |||
var fs = require("fs"); | |||
var util = require('util'); | |||
|
|||
/* | |||
* 非同期でファイルを読み込む関数 | |||
*/ | |||
(function test() { | |||
// 非同期でファイル読み込み(パスの指定は、nodeを起動しているパスからの相対パスになる) | |||
fs.readFile("./testdata", "utf8", function (err, data) { | |||
console.log("readFileを実行した!"); | |||
console.log(data); // 読み込んだファイルの内容を出力する | |||
}); | |||
// 処理される順番が交錯するのに注目してください | |||
console.log("readFile呼び出し終了"); | |||
// 以下の処理が終了した後、アイドル状態になってから上の非同期処理が行われる(キュー内の処理を順に呼び出すため) | |||
// 一定時間サーバを酷使するのでテスト環境で実行してください | |||
for(var i = 0, len = 10000; i < len; ++i) { | |||
util.print("."); | |||
} | |||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,33 +1,33 @@ | |||
/* | /* | ||
* hello, world | * hello, world | ||
* IPなど設定:http://testcording.com/?p=1164 | * IPなど設定:http://testcording.com/?p=1164 | ||
*/ | */ | ||
/* | /* | ||
* パラメータ | * パラメータ | ||
*/ | */ | ||
var IP_ADDRESS = "localhost"; | var IP_ADDRESS = "localhost"; | ||
var PORT = 1337; | var PORT = 1337; | ||
|
|
||
/* | /* | ||
* モジュール読み込み | * モジュール読み込み | ||
*/ | */ | ||
var fs = require("fs"); | var fs = require("fs"); | ||
var util = require('util'); | var util = require('util'); | ||
|
|
||
/* | /* | ||
* 非同期でファイルを読み込む関数 | * 非同期でファイルを読み込む関数 | ||
*/ | */ | ||
(function test() { | (function test() { | ||
// 非同期でファイル読み込み(パスの指定は、nodeを起動しているパスからの相対パスになる) | // 非同期でファイル読み込み(パスの指定は、nodeを起動しているパスからの相対パスになる) | ||
fs.readFile("./testdata", "utf8", function (err, data) { | fs.readFile("./testdata", "utf8", function (err, data) { | ||
console.log("readFileを実行した!"); | console.log("readFileを実行した!"); | ||
console.log(data); // 読み込んだファイルの内容を出力する | console.log(data); // 読み込んだファイルの内容を出力する | ||
}); | }); | ||
// 処理される順番が交錯するのに注目してください | // 処理される順番が交錯するのに注目してください | ||
console.log("readFile呼び出し終了"); | console.log("readFile呼び出し終了"); | ||
// 以下の処理が終了した後、アイドル状態になってから上の非同期処理が行われる(キュー内の処理を順に呼び出すため) | // 以下の処理が終了した後、アイドル状態になってから上の非同期処理が行われる(キュー内の処理を順に呼び出すため) | ||
// 一定時間サーバを酷使するのでテスト環境で実行してください | // 一定時間サーバを酷使するのでテスト環境で実行してください | ||
for(var i = 0, len = 10000; i < len; ++i) { | for(var i = 0, len = 10000; i < len; ++i) { | ||
util.print("."); | util.print("."); | ||
} | } | ||
})(); | })(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
/* | |||
* hello, world | |||
* IPなど設定:http://testcording.com/?p=1164 | |||
*/ | |||
/* | |||
* パラメータ | |||
*/ | |||
var IP_ADDRESS = "localhost"; | |||
var PORT = 1337; | |||
var startServer= function () { | |||
/* | |||
* サーバ起動時に表示するログ(起動したことが分かりやすい) | |||
*/ | |||
console.log("Server running at http://" + IP_ADDRESS + ":" + PORT + "/"); | |||
console.log("サーバを終了する際は[ctrl + c]を押してください"); | |||
}; | |||
|
|||
/* | |||
* モジュール読み込み | |||
*/ | |||
var http = require("http"); | |||
|
|||
/* | |||
* サーバの作成 | |||
*/ | |||
var server = http.createServer(); | |||
|
|||
/* | |||
* requestイベント受信時の処理(イベントハンドラ)を作成する | |||
*/ | |||
server.on("request", function(req, res) { | |||
// リクエストされたURLをログに表示(ブラウザからアクセスされるたびにコンソールへ出力する) | |||
console.log(req.url); | |||
// ヘッダーの送信 送信するデータのタイプはtext/plain | |||
res.writeHead(200, {"Content-Type": "text/plain"}); | |||
// 中身の文字列を送信 | |||
res.end("hello, world! : URL " + req.url); | |||
}); | |||
|
|||
/* | |||
* イベント待受状態を開始する | |||
*/ | |||
server.listen(PORT, IP_ADDRESS, startServer); |
Oops, something went wrong.