For Episode 13: https://code.tutsplus.com/tutorials/quick-tip-use-swfobject-to-embed-your-flash-content--active-9726
const express = require("express");
const app = express();
const request = require("request");
//Sets the public folder as the external file folder
app.use(express.static("public"));
//Officially sets the view engine as ejs, therefore setting the default file type for readering to .ejs
app.set("view engine", "ejs");
app.get("/", function(req, res){
res.render("homepage");
});
app.get("/game/:title/:creator/:width/:height/:fileName/:thumbnailFile", function(req, res){
res.render("game", {
title: req.params.title,
creator: req.params.creator,
width: req.params.width,
height: req.params.height,
fileName: req.params.fileName,
thumbnailFile: req.params.thumbnailFile
});
});
app.get("/list", function(req, res){
//Our ghetto database
const gamesData = [
{
title: "American Racing",
creator: "turboNuke",
width: 640,
height: 480,
fileName: "americanracing.swf",
thumbnailFile: "americanracingpicture.jpg"
},
{
title: "Generic Defense Game",
creator: "PyschoGoldfish",
width: 640,
height: 480,
fileName: "genericdefense.swf",
thumbnailFile: "GenericDefenseGame.png"
},
{
title: "Learn to Fly 2",
creator: "light_bringer777",
width: 640,
height: 480,
fileName: "embeddable_115608.swf",
thumbnailFile: "ltf2.jpg"
},
{
title: "Wonderputt",
creator: "dampgnat",
width: 750,
height: 650,
fileName: "wonderputt.swf",
thumbnailFile: "pop-wonderputt.jpg"
}
]
res.render("list", {
gamesData: gamesData
});
});
app.listen("3000", function(){
console.log("Gaming Website has started up! Made by Illuminati Productions.");
});
<% include partials/header %>
<h1>This is all of the games we have:</h1>
<div class="row">
<% for(var i = 0;i < gamesData.length; i++){ %>
<div class="col-md-4">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="/games/thumbnails/<%= gamesData[i].thumbnailFile %>" style="height: 180px">
<div class="card-body">
<h5 class="card-title"><%= gamesData[i].title %></h5>
<p class="card-text">Game created by <%= gamesData[i].creator %></p>
<a href="/game/<%= gamesData[i].title %>/<%= gamesData[i].creator %>/<%= gamesData[i].width %>/<%= gamesData[i].height %>/<%= gamesData[i].fileName %>/<%= gamesData[i].thumbnailFile %>" class="btn btn-primary">Play Game</a>
</div>
</div>
</div>
<% } %>
</div>
<% include partials/footer %>
<% include partials/header %>
<h2>Game Title: <%= title %></h2>
<h3>Game Creator: <%= creator %></h3>
<!-- Game will go here -->
<div id="game">
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
<script type="text/javascript" src="/swf/src/swfobject.js"></script>
<script>
var el = document.getElementById("game");
swfobject.embedSWF("/games/<%= fileName %>", el, <%= width %>, <%= height %>, 9, "/swf/expressInstall.swf");
</script>
<% include partials/footer %>