htmlCopy code
<!-- views/index.ejs -->
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Page</title>
</head>
<body>
<h1>Hello, <%= username %>!</h1>
<p>Today is <%= date %>.</p>
</body>
</html>
javascriptCopy code
// server.js
const express = require('express');
const app = express();
const port = 3000;
// Set the view engine to EJS
app.set('view engine', 'ejs');
// Sample data for rendering the dynamic page
const data = {
username: 'John',
date: new Date().toLocaleDateString(),
};
// Route to render the dynamic page
app.get('/', (req, res) => {
res.render('index', data);
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});