-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 1.12 KB
/
app.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
41
42
43
async function start() {
const express = require('express');
const serveIndex = require('serve-index')
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
const console = require('./console.js');
//view ejs
app.set('view engine', 'ejs');
//public folder
app.use(express.static('public'));
app.use('/news', express.static('news'), serveIndex('news', {'icons': true}))
app.use('/newsJSON', express.static('newsJSON'), serveIndex('newsJSON', {'icons': true}))
io.on('connection', (socket) => {
console.debug('a user connected');
socket.on('fetch', () => {
console.debug('fetching');
})
socket.on('disconnect', () => {
console.debug('user disconnected');
});
});
app.get('/', (req, res) => {
res.render('index');
});
server.listen(8000, () => {
console.log("Server started on port 8000");
});
}
module.exports = {
start
}