Created
April 8, 2015 12:35
-
-
Save kevin-shu/f0b75fed66242019b984 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var http = require('http'), | |
fs = require('fs'); | |
var count = 0; | |
http.createServer(function (req, res) { | |
// 計數器加一 | |
count++; | |
// 將計數器中的數字寫入"count.txt" | |
fs.writeFile("count.txt",count, function(){}); | |
// 別管這行 | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
// 印出目前人數 | |
res.end('Hello, you are the '+count+"st guest!"); | |
}).listen(8080, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:8080/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment