var http = require('http');
var server = http.createServer();
var datas = {
"grade": "1",
"name": "企业负责人"
}
server.listen('9999','172.100.101.201');
server.on('listening',function(){
console.log('服务启动');
})
server.on('error', function(err) {
console.log(err);
});
server.on('request', function(request, response) {
console.log(new Date() + '有请求了...');
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with , content-type");
response.end(JSON.stringify(datas));
});
网友评论