forked from sguptatgen/cgrn-repository-helios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (25 loc) · 967 Bytes
/
app.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
//Initialization variables for all dependencies.
var express = require('express');
var app = express();
var https = require('https');
var http = require('http');
var db = require('./db.js');
var cons = require('consolidate');
var swig = require('swig');
var async = require("async");
var port = 8080;
//Sets up templating engine for establishing directory structure.
app.engine('.html', cons.swig);
app.set('view engine', 'html')
swig.init({ encoding: 'utf-8', root: 'templates/'});
app.set('views', 'templates/');
var homepage = require('./views/homepage.js');
app.get("/",homepage.get);
//Places static files in the public folder.
app.use(express.static(__dirname + '/public'));
//Sets up the web socket and localhost server at the specified port. (8080).
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
io.sockets.on('connection', homepage.loader);
server.listen(port);
console.log("Listening on port " + port);