Skip to content

Instantly share code, notes, and snippets.

@lamorbidamacchina
Created November 22, 2021 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamorbidamacchina/7c7135369f6ee40d7973dfa124b6340b to your computer and use it in GitHub Desktop.
Save lamorbidamacchina/7c7135369f6ee40d7973dfa124b6340b to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
app.use(express.static('public'));
var http = require('http').Server(app);
var port = process.env.PORT || 3001;
var io = require('socket.io')(http);
io.on('connection', function(socket) {
console.log('new connection');
socket.on('message', function(msg) {
console.log('Got message from client: ' + msg);
});
});
app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/default.html');
});
http.listen(port, function() {
console.log('listening on *: ' + port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment