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

  • NGINX Cookbook
  • Tim Butler
  • 84字
  • 2021-07-03 00:04:28

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); 
主站蜘蛛池模板: 会宁县| 岑巩县| 陇川县| 潮州市| 丹棱县| 应用必备| 友谊县| 望奎县| 宁强县| 舒兰市| 清苑县| 全椒县| 寿阳县| 监利县| 四会市| 浪卡子县| 安化县| 新宾| 广丰县| 大田县| 临洮县| 银川市| 平湖市| 阳东县| 青浦区| 高唐县| 奉节县| 互助| 扎鲁特旗| 信阳市| 甘孜县| 思茅市| 湾仔区| 政和县| 台州市| 明光市| 神农架林区| 固阳县| 平和县| 长乐市| 鄢陵县|