-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (28 loc) · 838 Bytes
/
Copy pathserver.js
File metadata and controls
36 lines (28 loc) · 838 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
32
33
34
const express = require('express')
const http = require('http')
const path = require('path')
const socketio = require('socket.io')
const app = express()
const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use('/', express.static(__dirname))
app.get('/', (req, res) => {
track.ready = false
res.sendFile(path.join(__dirname + '/index.html'))
})
app.get('/simulator', (req, res) => {
track.ready = false
res.sendFile(path.join(__dirname + '/simulator.html'))
})
app.get('/camera', (req, res) => {
track.ready = false
res.sendFile(path.join(__dirname + '/camera.html'))
})
const server = http.Server(app)
server.listen(4000, () => {
console.log('listening 4000')
})
const io = socketio(server)
const Track = require('./track')
const track = new Track()
io.on('connection', track.start.bind(track))