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:'index.html'}));
- app.get('/login',function(req,res){
- res.sendFile(__dirname+'/index.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(3000);
- console.log("running at 3000");
Add Comment
Please, Sign In to add comment