node学习笔记
直接上代码开始吧!go!
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('');
var fs=require("fs");
var data=fs.readFileSync('test.txt');
var strAll=data.toString()+'Hello 一名儿';
res.end(strAll);
}).listen(6666, "127.0.0.1");
var fs=require("fs");
var data=fs.readFileSync('test.txt');
console.log(data);
console.log(data.toString());
console.log("程序执行结束!");
console.log('我是一名儿。我的服务器是http://127.0.0.1:6666/');
var fs = require("fs");
fs.readFile('test.txt', function (err, data) {
if (err) return console.error(err);
console.log(data.toString());
});
console.log("程序执行结束!");
运行结果截图
先看下我的环境,如何安装配置我就不多说了
PS :我这个是git的bush,看着舒服,还可以用”ls”呢!
![Nodejs学习笔记(一)_第1张图片](http://img.e-com-net.com/image/info8/446eeccabc244cbfa6cc309d9be4b076.jpg)
hello world!打helloworld就像篮下投篮一样,基础的第一步,一定要得分。
![Nodejs学习笔记(一)_第2张图片](http://img.e-com-net.com/image/info8/2de64b7dd1e64324b0bdb1582e628061.jpg)
来看看阻塞与非阻塞的区别。
![Nodejs学习笔记(一)_第3张图片](http://img.e-com-net.com/image/info8/0b0469c8c65f47c8b22d15b9103edb03.png)
主要是发现了buffer
![Nodejs学习笔记(一)_第4张图片](http://img.e-com-net.com/image/info8/11e847b3cb144105abc3f3bbbdd964ed.png)
中文的支持问题从来是我们常遇到的麻烦
![Nodejs学习笔记(一)_第5张图片](http://img.e-com-net.com/image/info8/b853a84fa50149c69813b96455440e50.jpg)