服务器封装

174 阅读1分钟
let app = new lcApp()
app.on('/',(re1,res)=>{
    res.end("这是首页")
}
app.run(80,()={
    console.log("成功运行")
}

封装: 1.构造函数能够实例化app对象 2.app.on() 可以添加路由器的事件,根据请求的路径,去执行不同的内容 3.app.run(port,callback) 让服务器运行起来 (端口,回调函数)