官术网_书友最值得收藏!

Getting ready

Express is so minimalistic that it doesn't come with any boilerplate code to get you started. There are a number of generators out there which can set up a structure for you, however, I'm going to stick to a simple web page and a WebSocket for testing. Here's my Express file:

var express = require('express'); 
var app = express(); 
var expressWs = require('express-ws')(app); 
 
app.get('/', function (req, res) { 
    res.send('Nginx demo!!!'); 
}); 
 
app.ws('/echo', function(ws, req) { 
    ws.on('message', function(msg) { 
        ws.send(msg); 
    }); 
}); 
 
app.listen(3000); 
主站蜘蛛池模板: 龙胜| 静宁县| 东台市| 黑龙江省| 镇巴县| 铜山县| 六盘水市| 湘西| 安徽省| 嘉鱼县| 泗水县| 贞丰县| 特克斯县| 玉环县| 景德镇市| 绥宁县| 保山市| 钟山县| 上高县| 抚松县| 门头沟区| 阿图什市| 南投县| 永善县| 衢州市| 竹山县| 大宁县| 清镇市| 马山县| 黄山市| 板桥市| 周宁县| 普陀区| 永州市| 湾仔区| 和林格尔县| 拉萨市| 微山县| 师宗县| 阿图什市| 萨迦县|