socket.io tested by angelus

main
Angelus Vela 8 hours ago
parent 291f72380a
commit 2b4072a6b7

@ -0,0 +1,8 @@
<html>
<body>
<h1> Hello Angelus from index.html file </h1>
<p>This is some text </p>
<script src='/socket.io/socket.io.js'></script>
<script>var socket = io();</script>
</body>
</html>

@ -2,12 +2,18 @@ const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require('socket.io');
const io = new Server(server);
app.get('/', (req, res) => {
//res.send('<h1> Hello Angelus!</h1>');
res.sendFile(__dirname + '/index.html');
});
io.on('connection',(socket) => {
console.log ('A new user is connected');
});
server.listen(3333, () => {
console.log('listen on part 3333');
});

@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.22.3"
"express": "^4.22.3",
"socket.io": "^4.8.4"
}
}

Loading…
Cancel
Save