码迷,mamicode.com
首页 > Web开发 > 详细

nodejs新建服务器

时间:2016-11-21 11:11:07      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:bsp   utf-8   html   text   清除   ejs   nod   write   read   

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新建服务器

标签:bsp   utf-8   html   text   清除   ejs   nod   write   read   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!