html - ExpressJs Cannot Get /register Error -


i'm having error using expressjs. says "cannot /register.html". don't have idea how solve this. show register.html /register error. btw here's code guys. guys, hope can me, i've googled errors 1 hr can't still make work.

app.js

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) && pass && pass == req.body.user.password )        res.write( "successfully logged in!" );    else if ( pass == false)      res.write("account not exist")    else        res.write( "password 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); 

here's login.html

<html> <head></head> <body> <p> <form method="post" action="/login">  username: <input type="text" name="user[username]"> <br> password: <input type="text" name="user[password]"> <br>  <input type="submit" value="submit"> <br> <a href="/register.html">register!</a> </form> </p> </body> </html> 

here's register.html

<html> <head></head> <body> <p> <form method="post" action="/register"> first name: <input type="text" name="user[fname]"> <br> last name: <input type="text" name="user[lname]"> <br> username: <input type="text" name="user[username]" > <br> password: <input type="text" name="user[password]"> <br> email: <input type="text" name="user[email]"> <br> mobile number: <input type="text" name="user[mobile]"> <br> <input type="submit" value="submit"> </p> </form> </body> </html> 

you route /register should this:

app.get("/register", function (req, res) {   res.sendfile(__dirname + "/register.html"); }); 

currently have put both login , register view on "/", first work.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -