title: Implementing simple upvote downvote program
body: <p>I am using express.js and jQuery to create a basic upvote downvote program. Basically the voting buttons increment/decrement by one whenever pressed and the result of each button click is displayed below. Nothing happens when the buttons are clicked, not even a <code>Cannot POST /</code>. I am not sure what is causing the error. This is what my <code>main.js</code> file looks like:</p>
  
  <pre><code>$(document).ready(function(){
  $("#up").click(function(){
      var up = $.post("/upvote", {changeBy: 1}, function(dataBack){
  
          $("#upvote").text(dataBack);
      });
  
  });
  $("#down").click(function(){
      var down = $.post("/downvote", {changeBy: 1},
      function(dataBack){
          $("#downvote").text(dataBack);
      });
  
    });
  });
  </code></pre>
  
  <p>and then on the server side <code>server.js</code>, I have this: </p>
  
  <pre><code>var express = require("express");
  var app = express();
  var bodyParser = require("body-parser");
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(express.static("public"));
  
  var inc = 0;
  var dec = 0;
  
  app.post("/upvote", function(req, res){
     res.setHeader("Content-Type", "application/json");
     inc += parseFloat(req.body.changeBy);
     res.write(JSON.stringify(inc));
     res.end();
  
  });
  app.post("/downvote", function(req, res){
     res.setHeader("Content-Type", "application/json");
     dec -= parseFloat(req.body.changeBy);
     res.write(JSON.stringify(dec));
     res.end();
  
   });
  
  
  var server = app.listen(8081, function () {
  
      var host = server.address().address
      var port = server.address().port
  
      console.log("Example app listening at http://%s:%s", host, port)
  
  })
  </code></pre>
  
  <p>A bit of HTML:</p>
  
  <pre><code>&lt;div class="buttons"&gt;
  &lt;button id="down"&gt;Downvote&lt;/button&gt;
      &lt;p id="downvote"&gt;&lt;/p&gt;
  &lt;button id="up"&gt;Upvote&lt;/button&gt;
      &lt;p id="upvote"&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>