
上QQ阅读APP看书,第一时间看更新
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);