-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (28 loc) · 1.04 KB
/
Copy pathapp.js
File metadata and controls
36 lines (28 loc) · 1.04 KB
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
'use strict';
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var fs = require('fs');
var path = require('path');
var mp = require('multiparty');
var routes = require('./routes');
var connect = require('./lib/connect.js');
var configFile = './config.json';
if(!fs.existsSync(configFile)) {
console.log('config.json does not exists. use template file.');
configFile = './config.template.json';
}
var config = JSON.parse(fs.readFileSync(configFile).toString());
app.use('/', express.static(__dirname + '/public'));
app.use('/highlight', express.static(__dirname + '/node_modules/highlight.js'));
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('config', config);
app.get('/', routes.index);
app.post('/edit', routes.edit);
io.of('/edit').on('connection', connect.on);
http.listen(config.port, config.host, function() {
console.log('listening on ' + config.host + ':' + config.port.toString());
});
module.exports = app;