title: Express & Jade - Cannot GET / template
body: <p>I'm new to Express and I'm trying to convert this project</p>
  
  <p><a href="https://github.com/shawn-simon-developer/NodeAngularProxy" rel="nofollow">https://github.com/shawn-simon-developer/NodeAngularProxy</a><a href="https://github.com/shawn-simon-developer/NodeAngularProxy" rel="nofollow">https://github.com/shawn-simon-developer/NodeAngularProxy</a>
  into one where I can use Jade.
  I've installed Jade via npm. My folder structure looks like this:</p>
  
  <pre><code>myProject
  --app
  ----css (inside e.g. bootstrap)
  ----index.jade
  ----js
  ------controllers
  ------services
  ----libs
  ----templates
  ------main.jade
  --index.js
  --node_modules
  ----(tons of modules in here e.g.)
  ----jade
  ----sass
  ----express
  --package.json
  </code></pre>
  
  <p>index.js looks like this:</p>
  
  <pre><code>/**
   * Module dependencies.
   */
  var express = require('express');
  var jade = require('jade');
  var httpProxy = require('http-proxy');
  var bodyParser = require('body-parser');
  
  var apiForwardingUrl = 'http://api.open-notify.org/astros.json?';
  
  // Solution for forwarding from http to https taken from:
  // http://stackoverflow.com/questions/15801014/how-to-use-node-http-proxy-for-http-to-https-routing
  var proxyOptions = {
      changeOrigin: true
  };
  
  httpProxy.prototype.onError = function (err) {
      console.log(err);
  };
  
  var apiProxy = httpProxy.createProxyServer(proxyOptions);
  
  console.log('Forwarding API requests to ' + apiForwardingUrl);
  
  // Node express server setup.
  var server = express();
  server.set('port', 3000);
  server.use(express.static(__dirname + '/app'));
  
  server.all("/space/*", function(req, res) {
      apiProxy.web(req, res, {target: apiForwardingUrl});
  });
  
  server.use(bodyParser.json());
  server.use(bodyParser.urlencoded({
      extended: true
  }));
  
  // Start Server.
  server.listen(server.get('port'), function() {
      console.log('Express server listening on port ' + server.get('port'));
  });
  
  
  server.set('view engine', 'jade'); // register the template engine
  
  server.get('/templates/:name', function (req, res)
   { var name = req.params.name;
     res.render('templates/' + name);
  });
  </code></pre>
  
  <p>And then index.jade like this</p>
  
  <pre><code>html
    head
      title Angular App
      // Angular Modules
      script(type='text/javascript', src='libs/angular/angular.js')
      script(type='text/javascript', src='libs/angular-route/angular-route.js')
      script(type='text/javascript', src='libs/jquery/jquery.js')
      // CSS Modules
      link(rel='stylesheet', type='text/css', href='css/bootstrap/bootstrap.min.css')
    body(ng-app='app')
      .container(ng-view='')
    // JS Modules
    script(type='text/javascript', src='js/app.js')
    script(type='text/javascript', src='js/controllers/MainCtrl.js')
    script(type='text/javascript', src='js/services/apiService.js')
  </code></pre>
  
  <p>and finally main.jade</p>
  
  <pre><code>{{ctrl.test}}
  
  p {{ctrl.wikiData | json}}
  
  h1 test
  </code></pre>
  
  <p>that's it. I can start the server using <code>node index.js</code> in the root of the project. however when I go to my <code>localhost:3000</code> I get the <code>Cannot GET /</code> issue that many others also seem to have. However, since I'm new to Node and Express I haven't been able to generalise the answers on other questions and solve my own. 
  Could anyone help me in what's going wrong here?
  thanks already!</p>
  
  <p><strong>EDIT 1:</strong>
  I have added </p>
  
  <pre><code>server.set('views', __dirname + '/app/templates');
  server.get('/', function (req, res) { res.render('index', {}); }); 
  server.get('/', function (req, res) {
       res.send('hello');
  });
  </code></pre>
  
  <p>to the end of index.js and moved the index.jade file inside the templates folder. Now what I'm getting is a log to the console like this:</p>
  
  <pre><code>angular.js:10506 GET http://localhost:3000/templates/main 404 (Not Found)
  </code></pre>
  
  <p>That's one step further but not a solution yet</p>