forked from DamienDabernat/ml5-accelerometer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (37 loc) · 1.2 KB
/
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
41
42
43
44
45
46
47
const express = require('express');
const { createServer } = require('node:http');
const { join } = require('node:path');
const { Server } = require('socket.io');
const path = require('path')
const app = express();
app.use('/sound', express.static(path.join(__dirname, 'sound')))
app.use('/run', express.static(path.join(__dirname, 'run')))
app.use('/video_proj', express.static(path.join(__dirname, 'video_proj')))
app.use('/model', express.static(path.join(__dirname, 'model')))
const server = createServer(app);
const io = new Server(server);
console.log(__dirname)
app.get('/projo', (req, res) => {
res.sendFile(join(__dirname, '/video_proj/index.html'));
});
app.get('/a', (req, res) => {
res.sendFile(join(__dirname, 'index.html'));
});
app.get('/', (req, res) => {
res.sendFile(join(__dirname, '/run/index.html'));
});
io.on('connection', (socket) => {
console.log('a user connected websocket');
socket.on('triangle', (msg) => {
io.emit("triangle", "coucou")
})
socket.on('sort1', (msg) => {
io.emit("sort1", "coucou")
})
socket.on('sort2', (msg) => {
io.emit("sort2", "coucou")
})
});
server.listen(4000, () => {
console.log('server running at http://localhost:4000');
});