-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (34 loc) · 1011 Bytes
/
server.js
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
32
33
34
35
36
37
38
39
40
const express = require('express');
const http = require('http');
const fs = require('fs');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
const server = http.Server(app);
const io = require('socket.io')(server);
app.set('view engine', 'hbs');
app.engine('hbs', hbs({
layoutsDir: __dirname + '/views/layouts',
extname: 'hbs',
defaultLayout: 'layout'
}));
app.get('/', (req, res) => {
res.render('index')
});
app.get('/index', (req, res) => {
res.render('index')
});
app.get('/admin', (req, res) => {
res.render('admin')
});
app.get('/favicon.ico', (req, res) => res.status(204));
app.use(express.static('assets'));
//Find port and listen on that port
const PORT = process.env.PORT || 3000;
server.listen(PORT, () => console.log(`Server started on port ${PORT}`));
console.log('Server running');
io.sockets.on('connection', (socket) => {
socket.on("change_video_admin", (embed) => {
socket.broadcast.emit("change_video", embed);
});
});