Spaces:
Sleeping
Sleeping
Update index.js
Browse files
index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
const express = require('express');
|
2 |
const http = require('http');
|
3 |
const socketIo = require('socket.io');
|
|
|
4 |
|
5 |
const app = express();
|
6 |
const server = http.createServer(app);
|
@@ -11,8 +12,12 @@ const io = socketIo(server, {
|
|
11 |
// Store connected users
|
12 |
const users = {};
|
13 |
|
|
|
|
|
|
|
|
|
14 |
app.get('/', (req, res) => {
|
15 |
-
res.
|
16 |
});
|
17 |
|
18 |
// Listen for connections
|
@@ -51,5 +56,5 @@ io.on('connection', (socket) => {
|
|
51 |
|
52 |
// Start the server
|
53 |
server.listen(7860, () => {
|
54 |
-
console.log('Server is running on http://localhost:
|
55 |
});
|
|
|
1 |
const express = require('express');
|
2 |
const http = require('http');
|
3 |
const socketIo = require('socket.io');
|
4 |
+
const path = require('path');
|
5 |
|
6 |
const app = express();
|
7 |
const server = http.createServer(app);
|
|
|
12 |
// Store connected users
|
13 |
const users = {};
|
14 |
|
15 |
+
// Serve static files from the public directory
|
16 |
+
app.use(express.static(path.join(__dirname, 'public')));
|
17 |
+
|
18 |
+
// Route to serve the index.html file
|
19 |
app.get('/', (req, res) => {
|
20 |
+
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
21 |
});
|
22 |
|
23 |
// Listen for connections
|
|
|
56 |
|
57 |
// Start the server
|
58 |
server.listen(7860, () => {
|
59 |
+
console.log('Server is running on http://localhost:7860');
|
60 |
});
|