cyber, зачем вы упорно обращаетесь к файлу? По аналогии с PHP
тут не получится
Надо с начала.
Создаем файл "server.js"
var http = require('http');
http.createServer(function (req, res){
if(req.url == '/vote'){
res.writeHead(200, {'Content-Type': 'text/plain;'});
var now = new Date();
var timeStr = now.getHours() + ':' + now.getMinutes() + ':'+now.getSeconds();
res.end('Голос принят: ' + timeStr);
}
else{
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf-8'});
res.end('Hello World!');
}
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
Сохраняем. В директории с "server.js" к консоли (в случае винды -- cmd.exe)
Заходим браузером по адресу :
http://127.0.0.1:8080/
Далее, надеюсь, все понятно станет.