-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (24 loc) · 738 Bytes
/
server.js
File metadata and controls
32 lines (24 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const express = require('express');
const http = require('http');
const { Server } = require("socket.io");
const path = require('path');
const initChat = require('./public/js/chat');
const app = express();
const server = http.createServer(app);
const io = new Server(server);
app.use(express.static('public'));
// Initialize Chat
initChat(io);
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'sign-in.html'));
});
app.post('/submit-your-form', (req, res) => {
res.redirect('/chat');
});
app.get('/chat', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'chat.html'));
});
const PORT = 3000;
server.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});