title: Display data in html/js file using NodeJs from mysql database
body: <p>My index.js file is </p>
  
  <pre><code>var express         = require('express');
  var  app            = express();
  var path            = require('path');
  var router          = express.Router();
  var data            = require('./data/jsonData');
  var createDatabase  = require('./data/db');
  var careateTable    = require('./data/createTable');
  var insert          = require('./data/insert');
  var bodyParser      = require('body-parser');
  var select          = require('./data/select');
  
  
  app.use(express.static(path.join(__dirname, 'www')));
  app.use(express.static(path.join(__dirname, 'form')));
  app.use(bodyParser());
  app.get('/' , function (req , res) {
      res.sendFile(path.join(__dirname + '/www/index.html'));
  });
  
  app.get('/data' ,function (req , res) {
      res.json(data);
  });
  app.get('/form' ,function (req , res) {
      res.sendFile(path.join(__dirname + '/form/index.html'));
  });
  app.post('/form' ,function (req , res) {
      console.log(req.body.user);
      console.log(req.body.password);
      insert.insertModule(req.body.user , req.body.password);
      res.sendFile(path.join(__dirname + '/www/index.html'));
  });
  app.get('/show' , function (req , res) {
      var i ;
     select.select( function (err, results) {
         if (err == 'error') {
             console.log(err);
         } else {
             console.log(results);
             res.send(results.username);
         }
     });
  
  });
  
  app.listen(3000);
  console.log("App is listning on port 3000");
  </code></pre>
  
  <p>and select.js is</p>
  
  <pre><code>var mysql = require('mysql');
  var con = mysql.createConnection({
      host: "localhost",
      user: "root",
      password: "",
      database: "NodeDataBase"
  });
  con.connect(function (err) {
      if (err) throw err;
      console.log("Connected!");
  });
  
  module.exports  = {
      select: function (callback) {
          var sql = "SELECT username , password FROM login ";
          con.query(sql, function (err, result , fields) {
              if (err) {
                  callback("error", err)
              } else {
                  callback("success", result)
              }
          });
      }
  }
  </code></pre>
  
  <p>I want to show the results object data to html file , So how can i do this please suggest me.</p>
  
  <p>from a get request /show it will show all userdata fetched from the database</p>