-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
66 lines (46 loc) · 1.37 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Requirements
var express = require('express');
var socket = require('./lib/socket'); // socket library
var nunjucks = require('nunjucks'); //nunjucks
var url = require('url');
var habitat = require('habitat'); // for handing environment variables
habitat.load();
// Create the app
var app = express();
nunjucks.configure('views', {
autoescape: true,
express: app,
watch: true
});
//How to get something out of habitat, sample
var env = new habitat("port");
//This makes it so that static assets will be served from
//the 'public' folder when requested via the URL
app.use(express.static('public'));
// Views
app.get('/', function(req, res) {
res.render('index.html');
});
app.get('/multiplayer', function(req, res) {
res.render('multiplayer.html');
});
app.get('/pad', function(req, res) {
res.render('pad.html');
});
app.get('/local', function(req, res) {
res.render('local.html');
});
app.get('/single', function(req, res) {
res.render('single.html');
});
// Example of getting a parameter from a URL and passing it to a view
// app.get('/user/:user_id', function(req, res) {
// var user = req.params.user_id;
// res.render('user.html', { "user" : user });
// });
var server = app.listen(process.env.PORT, function () {
var host = server.address().address;
var port = server.address().port;
});
socket.server(server);
// server.listen(9999, '0.0.0.0');