var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/text'});
p2=readx("data.txt");
res.end(p2);
}).listen(1337, '127.0.0.1');
console.log("http://127.0.0.1:1337/");
function readx( filename ){
var fs = require("fs");
var fileContent = "";
var stat = fs.statSync(filename);
var fd = fs.openSync(filename, "r");
var bytes = fs.readSync(fd, stat.size, 0, "ascii");
fileContent += bytes[0];
fs.closeSync(fd);
return fileContent;
};
最終更新:2015年11月10日 15:45