title: Set Home Page in Express
body: <p>I have some server side code in node js, which creates a express js object and runs the server. The app loads the index.html page which is inside the public folder. I have never written the code to serve the home page (mention below), still it works.</p>
  
  <pre><code>app.get('*', (req, res) =&gt; {
      res.sendFile(path.join(__dirname, 'public/index.html'));
  });
  </code></pre>
  
  <p>I have not written this code so how does the index.html gets rendered. My understanding says express JS looks for the first instance of index.html page in all the static folders declared in the code and renders it, in my case the static folder is "publimc" and it has index.html at the root level.</p>
  
  <p>server code follows below, which I have written.</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var mongojs = require('mongojs');
  var db = mongojs('contactlist', ['contactlist']);
  var bodyParser = require('body-parser');
  
  
  app.use(express.static(__dirname + '/publimc'));
  app.use(bodyParser.json());
  
  app.get('/contactlist', function (req, res) {
    console.log('I received a GET request');
    db.contactlist.find(function (err, docs) {
    console.log(docs);  
    res.json(docs);
    }); 
  });
  
  app.listen(8000);
  console.log("Server running on port 8000");
  </code></pre>