forked from tobloef/card-fu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 987 Bytes
/
Copy pathserver.js
File metadata and controls
25 lines (20 loc) · 987 Bytes
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
// This file starts the both the Express server, used to serve the actual webpage,
// and the Socket.io server, used to handle the the realtime connection to the client.
var express = require("express");
var app = express();
var http = require("http").Server(app);
var io = require("./libs/game_manager").listen(http); // Start Socket.io server and let game_manager handle those connections
app.set("port", (process.env.PORT || 3001)); // Use either given port or 3001 as default
app.use(express.static("public")); // Staticly serve pages, using directory 'public' as root
// User connects to server
app.get("/", function(req, res) {
// Will serve static pages, no need to handle requests
});
// If any page not handled already handled (ie. doesn't exists)
app.get("*", function(req, res) {
res.status(404).send("Error 404 - Page not found");
});
// Start http server
http.listen(app.get("port"), function() {
console.log("Node app started on port %s", app.get("port"));
});