This game.html file is actually totally static, but it lives at a
dynamic path (which includes the game ID in the path), so within the
dynamic app we need to serve the static file. To arrange for this we
symlink to the static file. Note that we're not committing the symlink
to git since the destination location can differ on each system.
const express = require("express");
const cors = require("cors");
const body_parser = require("body-parser");
+const path = require("path");
const app = express();
app.use(cors());
});
}
+app.get('/', (request, response) => {
+ response.sendFile(path.join(__dirname, './game.html'));
+});
+
app.post('/register', (request, response) => {
const game = request.game;
game.add_player(request.body.name, request.body.character);