-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (32 loc) · 1.19 KB
/
index.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
const express = require('express');
const axios = require('axios');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const server = require('http').Server(app)
const io = require('socket.io')(server)
var { environment } = require('./environment');
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
next();
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/src'));
app.get('/',function(req,res) {
res.sendFile(path.join(__dirname+'/src/roulette.html'));
});
io.on('connection', (socket) =>{
console.log(`Connected to client ${socket.id}`)
socket.on('new bet', (data) => {
console.log('new bet', data);
})
});
server.listen(environment.port, () => {
console.log("Server started on port " + environment.port + ". Visit http://localhost:" + environment.port);
});