nodejs新建服务器
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/');
轉載于:https://www.cnblogs.com/maomi-frontE/p/6084691.html
總結
以上是生活随笔為你收集整理的nodejs新建服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 汽车轮胎的种类,怎么说别?
- 下一篇: iOS之开发中一些相关的路径以及获取路径