小火车~污污污 走起咯
var express = require('express');
var app = express();app.get('*',function (req,res) {
//__dirname是指当前目录加路径
res.sendFile(__dirname+req.url);});
//设值监听事件端口为8888
app.listen(8888,'localhost",function(err){
if(err){
console.log(err)
}else{
console.log("服务器启动成功")
}
});
是不是很高清.哈哈~ 不能再污了再污就写不去了. 以上就是常用的代码.
加载指令 node server.js
退出 ctril+C
登录本地网页查看:localhost:8888/(这里写你的html的名字).html