Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express=require('express');
- var app=express();
- var mongo=require('mongodb').MongoClient();
- app.use(express.static(__dirname+'/',{index:'loginpage.html'}));
- app.get('/login',function(req,res){
- res.sendFile(__dirname+'/loginpage.html');
- })
- app.get('/insert',function(req,res){
- var username=req.query.uname;
- var password1=req.query.pswd;
- mongo.connect("mongodb://localhost:27017/userdb",function(err,db){
- if(err) throw err;
- var myobj={name:username,Password:password1};
- db.collection("userCollection").insert(myobj,function(err,res){
- if(err) throw err;
- console.log("1 document inserted in userCollection");
- db.close();
- });
- });
- })
- app.listen(3005);
- console.log("running at 3005");
Add Comment
Please, Sign In to add comment