AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
4.4路由 ~~~ http://localhost:3000/index http://localhost:3000/login ~~~ 路由是指客户端请求地址与服务器端程序代码的对应关系。简单的说,就是**请求什么响应什么**。 ![](https://img.kancloud.cn/84/01/8401f26ab83d15775fcdf2a8aeb3dc86_821x428.png) 路由 (找页面) ~~~ /当客户端发来请求的时候 app.on(' request' ,(req, res) => { //获取客户端的请求路径 let { pathname } = url.parse (req.url) ; // || 或者的意思 满足其中一个即可 if (pathname = '/' || pathname == '/index') { res.end( '欢迎来到首页') ; } else if (pathname = = '/list') { res.end( '欢迎来到列表页页'); } else { res.end (抱歉您访问的页面出游了'); } }) ; ~~~ [cluster 集群 | Node.js API 文档 (nodejs.cn)](http://nodejs.cn/api/cluster.html#cluster_event_online) ![](https://img.kancloud.cn/d4/4f/d44f6515a37bd267fed5c619233626cd_1088x925.png) ![](https://img.kancloud.cn/b9/fe/b9fe293300d4deffd72cd8991405e4fd_649x313.png) # 代码实验 结构![](https://img.kancloud.cn/73/c5/73c53f3b87d8b2f56f8793179ce32b61_834x461.png) 开发 (页面路由) ![](https://img.kancloud.cn/a5/48/a548187cd4e990e90fa1c52e9dcbcecd_1395x939.png)