repl.it
@basicer/

httpbin

Nodejs

No description

fork
loading
Files
  • index.js
  • Packager files
  • package-lock.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const express = require('express');

const app = express();
var expressWs = require('express-ws')(app);

app.get('/', (req, res) => {
	res.json(req.headers)
});

app.listen(3000, () => {
	console.log('server started');
});

app.ws('/echo', function(ws, req) {
  ws.on('message', function(msg) {
    ws.send(JSON.stringify(req.headers));
  });
});