title: How to debug "Cannot POST /" error?
body: <p>I am getting this error:</p>
  
  <blockquote>
    <p>Cannot POST/.</p>
  </blockquote>
  
  <p>Below is the code I'm trying to execute.</p>
  
  <h1>Server.js </h1>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  var _ = require('underscore');
  var db = require('./db.js');
  var bcryptjs = require('bcryptjs');
  var middleware = require('./middleware.js')(db);
  var http = require('http').Server(app);
  var app = express();
  var PORT = process.env.PORT || 3000;
  var todos = [];
  var todoNextId = 1;
  app.use(express.static(__dirname + '/public')); 
  
  app.use(bodyParser.json());
  
  app.get('/', function(req, res) {
  res.send('Todo API Root');
  });
  
  app.get('/todos', middleware.requireAuthentication, function(req, res) {
  var query = req.query;
  var where = {
      userId: req.user.get('id')
  };
  
  if (query.hasOwnProperty('completed') &amp;&amp; query.completed === 'true') {
      where.completed = true;
  } else if (query.hasOwnProperty('completed') &amp;&amp; query.completed === 'false')      {
      where.completed = false;
  }
  
  if (query.hasOwnProperty('q') &amp;&amp; query.q.length &gt; 0) {
      where.description = {
          $like: '%' + query.q + '%'
      };
  }
  
  db.todo.findAll({
      where: where
  }).then(function(todos) {
      res.json(todos);
  }, function(e) {
      res.status(500).send();
  });
  
  });
  
  app.get('/todos/:id', middleware.requireAuthentication, function(req, res) {
  var todoId = parseInt(req.params.id, 10);
  
  db.todo.findOne({
      where: {
          id: todoId, 
          userId: req.user.get('id')
      }
  }).then(function(todo) {
      if (!!todo) {
          res.json(todo.toJSON());
      } else {
          res.status(404).send();
      }
  }, function(e) {
      res.status(500).send();
  });
  
  });
  
  app.post('/todos', middleware.requireAuthentication, function(req, res) {
  var body = _.pick(req.body, 'description', 'completed');
  
  
  db.todo.create(body).then(function(todo) {
      req.user.addTodo(todo).then(function () {
          return todo.reload();
      }).then(function (todo) {
          res.json(todo.toJSON());
      });
  }, function(e) {
      res.status(400).json(e);
  });
  
  });
  
  app.delete('/todos/:id', middleware.requireAuthentication, function(req, res) {
  var todoId = parseInt(req.params.id, 10);
  
  db.todo.destroy({
      where: {
          id: todoId,
          userId: req.user.get('id')
      }
  }).then(function(rowsDeleted) {
      if (rowsDeleted === 0) {
          res.send(404).json({
              error: 'No todo with id'
          });
      } else {
          res.status(204).send();
      }
  }, function() {
      res.status(500).send();
  });
  });
  
  app.put('/todos/:id', middleware.requireAuthentication, function(req, res) {
  var todoId = parseInt(req.params.id, 10);
  var body = _.pick(req.body, 'description', 'completed');
  var attributes = {};
  
  if (body.hasOwnProperty('completed')) {
      attributes.completed = body.completed;
  }
  
  if (body.hasOwnProperty('description')) {
      attributes.description = body.description;
  }
  
  db.todo.findOne({
      where: {
          id: todoId, 
          userId: req.user.get('id')
      }
  }).then(function(todo) {
      if (todo) {
          todo.update(attributes).then(function(todo) {
              res.json(todo.toJSON());
          }, function(e) {
              res.status(400).json(e);
          });
      } else {
          res.status(404).send();
      }
  }, function() {
      res.status(500).send();
  });
  });
  
  
  app.post('/users', function(req, res) {
  var body = _.pick(req.body, 'email', 'password');
  db.user.create(body).then(function(user) {
  res.json(user.toPublicJSON());
  }, function(e) {
      res.status(400).json(e);
  });
  
  });
  
  app.post('/users/login', function (req, res) {
  var body = _.pick(req.body, 'email', 'password');
  var userInstance;
  
  db.user.authenticate(body).then(function (user) {
      var token = user.generateToken('authentication');
      userInstance = user;
  
      return db.token.create({
          token: token
      });
  }).then(function (tokenInstance) {
      res.header('Auth',
  tokenInstance.get('token')).json(userInstance.toPublicJSON());
  }).catch(function () {
      res.status(401).send();
  });
  });    
  
  app.delete('/users/login', middleware.requireAuthentication, 
  function (req, res) {
  req.token.destroy().then(function () {
  res.status(204).send();
  }).catch(function () {
  res.status(500).send();
  });
  });
  
  db.sequelize.sync({force: true}).then(function() {
  app.listen(PORT, function() {
      console.log('Express listening on port ' + PORT + '!');
  });
  });
  </code></pre>
  
  <p>This is my app.js file</p>
  
  <pre><code>app.post('/users', function(req, res) {
  var body = _.pick(req.body, 'email', 'password');
  
  
  db.user.create(body).then(function(user) {
      res.json(user.toPublicJSON());
  }, function(e) {
      res.status(400).json(e);
  });
  
  });
  </code></pre>
  
  <p>I've been trying this but not getting through.Not sure whether the html file I have is correct. Want to create an html file to post from, but mine is refusing to respond.</p>