Skip to content

Instantly share code, notes, and snippets.

@kevin-shu
Created April 8, 2015 12:35
Show Gist options
  • Save kevin-shu/f0b75fed66242019b984 to your computer and use it in GitHub Desktop.
Save kevin-shu/f0b75fed66242019b984 to your computer and use it in GitHub Desktop.
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