// Magic8Ball Example // Source code file: main.js const express = require("express"); const app = express( ); const PORT = 3000; // Set View Engine to EJS app.set("view engine", "ejs"); // Array of 20 Magic 8-Ball Predictions const preds = ["It is certain.", "It is decidedly so.", "Without a doubt.", "Yes definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."]; // Define /prediction route. app.get("/prediction", (req, res) => { // Pass the preds array to the EJS page. res.render("magic-8ball", { predictions: preds}); }); // If undefined route is entered, show route-not-found page. app.get("*", (req, res) => { res.render("route-not-found.ejs"); }); // Start server for port 3000. app.listen(PORT, ( ) => { console.log(`Server listening on Port ${PORT}`); });