【发布时间】:2014-02-13 08:19:31
【问题描述】:
在 Node.js 中使用 express 时如何与客户端连接?
我们需要在客户端包含一个 .js 文件吗?
目标是使用“连接”按钮创建客户端,当我单击该按钮时,客户端连接到服务器,并且在页面上提醒服务器返回。
var app = require('express').createServer();
app.get('/', function(req, res){
res.send('hello world');
});
app.get('message', function(req, res){
console.log(req);
});
app.listen(3000);
【问题讨论】: