Port changed back to 3000

This commit is contained in:
Lucas Patenaude
2024-04-09 21:10:08 -06:00
parent 28d8fcffc2
commit fd53cdc24f
6 changed files with 49 additions and 42 deletions

View File

@@ -1,18 +1,25 @@
// create-league-routes.js
const express = require('express');
const app = express();
const exphbs = require('express-handlebars');
const app = express();
app.engine('hbs', exphbs({ extname: '.hbs' }));
app.set('view engine', 'hbs');
// Define the redirectToLeaguePage function
function redirectToLeaguePage(leagueName) {
window.location.href = '/views/pages/league-page/league-page.hbs?leagueName=' + encodeURIComponent(leagueName);
}
// Define a route to render the league-page.hbs template
app.get('/league-page/:leagueName', (req, res) => {
const leagueName = req.params.leagueName;
// Here you might fetch data related to the clicked league
// Pass the data to the template and render it
res.render('league-page', { leagueName });
res.render('league-page/league-page', { leagueName });
});
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});
// Export the app and redirectToLeaguePage function
module.exports = { app, redirectToLeaguePage };