nodejs
来源:互联网 发布:3799游戏盒软件 编辑:程序博客网 时间:2024/06/06 13:58
2. 环境变量的原理
3. 最基本的命令行操作
cd
dir
.
..
cls
path
4. node 命令
node script.js
node -v(查看版本)
node -h(查看帮助)
5. 服务器 helloworld 代码
1. 难点:参数是一个函数
2. 写一个服务器的基本过程
```
//5步创建服务器
1. http 模块的对象
2. createServer
3. server 去监听
4. 回调函数:1. 访问事件 -- 回调响应函数
5. 回调函数:2. 端口监听事件 -- 回调函数
```
6. 回调函数:
当有事件发生的时候,被调用的函数。
EADDRINUSE:::3000
E -- error
ADDR -- address
INUSE -- inuse
7.代码
/*
//5步创建服务器
1. http 模块的对象
2. createServer
3. server 去监听
4. 回调函数:1. 访问事件 -- 回调响应函数
5. 回调函数:2. 端口监听事件 -- 回调函数
*/
var http = require('http');
http.createServer(function (req, res) {
res.end('<h1>how are you</h1>');
}).listen(3000, function () {
console.log('server started');
});
//延时调用
/*var a;
var food;*/
function eat(food) {
console.log(food);
/* return function inner() {
console.log('2 second');
}*/
}
/*var b;*/
var food= 'apple';
setTimeout(eat, 2*1000,food);
//2秒后打印apple
1 0
- nodejs
- NodeJs
- nodejs
- nodejs
- nodejs
- nodejs
- nodejs
- nodejs
- nodejs
- nodejs
- NodeJs
- nodejs
- NodeJS
- nodejs
- nodejs
- nodejs
- NodeJS
- nodejs
- C++读取、写入配置文件
- Guice基本用法
- php-fallibility
- 1089. Insert or Merge (25)
- js实现瀑布流的两种方法
- nodejs
- tomcat出现Could not load the Tomcat server configuration at 。。异常解决办法
- HTTP协议的简单认识
- Linux多进程
- CodeFoeces732C 枚举
- 解题报告-PAT - Root of AVL Tree
- NSString之Category
- AfxBeginThread和CreateThread具体区别
- 美团推荐算法实践