What is EJS?
+EJS stands for Embedded JavaScript. It's a templating engine that lets us write JavaScript code directly inside our HTML files. Instead of just sending a static file, the server "renders" the page by running the JavaScript first. This allows us to pass data from our server (like a username or a list of posts) and dynamically build the HTML page before sending it to the user.
+🎲 Roll Dice Page
+This page demonstrates the most basic concept of EJS. The server generates a random number from 1 to 6 and passes this number to the dice.ejs template. The template then uses EJS tags (<%= num %>) to display the value. It also uses EJS logic (<% if (num == 6) { %>) to show a special message only if you roll a 6!
Dynamic Instagram Page
+This is a more advanced example. It uses dynamic routing to create a page for different users. When you visit a URL like /instagram/cats, the server grabs the "cats" part from the URL and uses it to find data in a data.json file. It then sends the entire user object (followers, posts, etc.) to the instagram.ejs template to build a custom profile page.
How to Use It:
+Our database (data.json) currently has these users. Click any of them to see their profile:
-
+
/instagram/cats
+ /instagram/dogs
+
+