var http = require('http');
var fs = require('fs');
http.createServer(function(req,res){
res.setHeader('Access-Control-Allow-Origin','*');
fs.readFile('../data/shuju.json',function(err,data){
if(err == null){
res.writeHead(200,{'Content-Type':'text/plain;charset=utf-8'});
res.end(data);
}else{
res.writeHead(404,{'Content-Type':'text/plain;charset=utf-8'});
res.end();
}
})
}).listen(8080);
console.log('服务器启动成功');
网友评论