首页 > Web开发 > 详细

nodejs新建服务器

时间:2016-11-21 11:10:14      阅读:208      评论:0      收藏:0      [点我收藏+]

var http = require(‘http‘);
// var optfile = require(‘./models/optfile‘);


http.createServer(function (request, response) {
  response.writeHead(200, {‘Content-Type‘: ‘text/html; charset=utf-8‘});
  if(request.url!=="/favicon.ico"){ //清除第2此访问
    console.log(‘访问‘);
    response.write(‘hello,world‘);
    //optfile.readfile("G:\\www\\nodejs\\one\\models\\aa.txt");
    // optfile.readfileSync("G:\\www\\nodejs\\one\\models\\aa.txt");
    response.end(‘hell,man‘);//不写则没有http协议尾
  }
}).listen(8000);


console.log(‘Server running at http://127.0.0.1:8000/‘);

nodejs新建服务器

原文:http://www.cnblogs.com/maomi-frontE/p/6084691.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!