title: ExpressJs Cannot Get /register Error
body: <p>I'm having an error using expressjs. It says "Cannot GET /register.html". I don't have any idea how to solve this. I would like to show register.html to /register but I always get an error. BTW here's my code guys. Thanks guys, I hope you can help me, I've googled this errors for 1 hr but I can't still make it work.</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var express = require("express");
  var app = express();
  var redis = require("redis");
  var client = redis.createClient();
  var reply;
  
  app.use(express.bodyParser());
  
  client.on("error", function (err) {
  console.log("error event - " + client.host + ":" + client.port + " - " + err);
  });
  
  app.get("/", function (req, res) {
  res.sendfile(__dirname + "/login.html");
  });
  
  app.get("/", function (req, res) {
  res.sendfile(__dirname + "/register.html");
  });
  
  app.post("/login", function (req, res) {
  res.sendfile(__dirname + "/login.html");
  console.log("--------------------");
  console.log(req.body.user.username);
  console.log(req.body.user.password);
  console.log("--------EOF---------");
  client.hmget( "credentials", req.body.user.username, function (err,pass) {
      console.log("req.body.username: " + req.body.user.username);
      console.log("req.body.password: " + req.body.user.password);
      console.log("pass: " + pass );
      console.log("err: " + err );
  
     if ( (!err) &amp;&amp; pass &amp;&amp; pass == req.body.user.password )
         res.write( "Successfully logged in!" );
     else if ( pass == false) 
      res.write("Account Does not Exist")
     else
         res.write( "Password is incorrect");
     res.end();
   });
  });
  
  
  app.post("/register", function (req, res) {
  res.redirect("/register.html");
  console.log("--------------------");
  console.log(req.body.user.fname);
  console.log(req.body.user.lname);
  console.log(req.body.user.username);
  console.log(req.body.user.pass);
  console.log(req.body.user.email);
  console.log(req.body.user.mobile);
  console.log(req.body.user.mydate);
  
  console.log("--------EOF---------");
  client.hmset("credentials",req.body.user.uname, "first_name",req.body.user.fname, 
  "last_name",req.body.user.lname, "username", req.body.user.uname, 
  "password", req.body.user.pass, "email", req.body.user.email,
  "mobile", req.body.user.mobile, redis.print);
  res.write("data inserted");
  res.end();
  
  });
  
  app.listen(1337);
  </code></pre>
  
  <p>Here's my <strong>login.html</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;
  &lt;form method="post" action="/login"&gt;
  
  Username: &lt;input type="text" name="user[username]"&gt; &lt;br&gt;
  Password: &lt;input type="text" name="user[password]"&gt; &lt;br&gt;
  
  &lt;input type="submit" value="Submit"&gt; &lt;br&gt;
  &lt;a href="/register.html"&gt;Register!&lt;/a&gt;
  &lt;/form&gt;
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here's my <strong>register.html</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;
  &lt;form method="post" action="/register"&gt;
  First Name: &lt;input type="text" name="user[fname]"&gt; &lt;br&gt;
  Last Name: &lt;input type="text" name="user[lname]"&gt; &lt;br&gt;
  Username: &lt;input type="text" name="user[username]" &gt; &lt;br&gt;
  Password: &lt;input type="text" name="user[password]"&gt; &lt;br&gt;
  Email: &lt;input type="text" name="user[email]"&gt; &lt;br&gt;
  Mobile Number: &lt;input type="text" name="user[mobile]"&gt; &lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>