title: Serving Dynamic Webpages with Node.js
body: <p>I am having a hard time understanding how exactly node.js serves dynamic content.
  So let's say we have the following code that renders a home page:</p>
  
  <pre><code>var express = require('express'),
      app = express();
  
  app.get('/', function(req,res){
      res.render('home.html');
  });
  </code></pre>
  
  <p>However, let's say this home page was supposed to be a user profile in which you are pulling user information from a database, which results in code:</p>
  
  <pre><code>var express = require('express'),
      mongoose = require('mongoose'),
      app = express();
  
  mongoose.connect('mongodb://localhost/ExampleDB');
  
  app.get('/:id', function(req,res){
      User.findOne({_id: req.id}, function (err, user){
         var name = user.name;
         var profilePic_uri = user.profilePic_uri;
         res.render('home.html');
  });
  </code></pre>
  
  <p>So, ideally home.html is just a template page, in which you set maybe the user's profile picture, their name, etc in the route handler. Right, because the idea behind node, is that this app.js should be able to handle pulling the dynamic content from a database at run time.  Where I am having trouble is understanding how exactly rendering dynamic pages work with node. The html page is a static page. You can't really render a php or a asp page because, well, that doesn't really make sense does it? </p>
  
  <p>Which leaves me with the question, how is it done?</p>