-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.js
26 lines (22 loc) · 800 Bytes
/
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
var Spider = require('./build/Spider').Spider;
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var serverConfig = require('./server.config');
io.on('connection', function (socket) {
socket.on('fetch start', function (data) {
Spider(data.url, socket);
});
});
server.listen(serverConfig.socketPort);
app.use(bodyParser());// WARNING
app.use('/js', express.static('./client/build'));
app.use('/css', express.static('./client/build'));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/client/index.html');
});
app.listen(serverConfig.httpPort, function () {
console.log('server start at 127.0.0.1:%s', this.address().port)
});