Node.js Express Bulk Website URL Up-Down Status Checker Using is-Up Library Full Project For Beginners

Node.js Express Bulk Website URL Up-Down Status Checker Using is-Up Library Full Project For Beginners

 

 

 

Welcome folks today in this post we will be building a bulk website url up-down status checker in node.js and express. All the source code of the application is given below.

 

 

 

Live Demo

 

 

 

 

You can see the live demo of app here

 

 

 

Screenshot

 

 

 

 

 

Get Started

 

 

 

In order to get started we need to initialize a node.js project

 

npm init -y

 

This will create a package.json file for your project

 

And now we need to install the following dependencies like this

 

npm i express

 

npm i nodemon

 

npm i is-up

 

After installing all these dependencies we need to make a index.js file and copy paste the following code

 

index.js

 

const express = require("express")

const isUp = require("is-up")

const bodyparser = require("body-parser");

const PORT = 4000;

const app = express();

app.set("view engine","ejs")

app.use(bodyparser.urlencoded({ extended: false }));

app.use(bodyparser.json());

app.post("/singledomainstatuschecker", async (req, res) => {
  var url = req.body.domain;

    var statusResult = await isUp(url);
    if(statusResult){
      res.json({
        domain: url,
        domainstatus:"Site is Running (200) OK",
      });
    }
    else{
      res.json({
        domain: url,
        domainstatus:"Site is Down (500) Not Ok",
      });
    }
});

app.get("/bulksitedownchecker", (req, res) => {
  res.render("bulksitedownchecker", { title: "FREE Bulk Website Up-Down Status Checker Online Tool - Best Bulk Website Uptime Checker Tool - FreeMediaTools.com" });
});



app.listen(PORT, () => {
  console.log(`App is listening on Port ${PORT}`);
});

 

See also  JavaScript Program to Include a JS file in Another JS File Using import/export Keyword Full Project For Beginners

 

Now inside the root directory make a views folder and inside this make a bulksitedownchecker.ejs file and copy paste the following code

 

 

views/bulksitedownchecker.ejs

 

 

 

<!DOCTYPE html>
<html>
  <head>
    <title>Currency Converter in Javascript</title>
    <link
      rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    />
  </head>
  <body>
      <div class="container">
          <h1 class="text-center">
              Bulk Website Up or Down Checker
          </h1>
          <form id="form">
            <div class="form-group">
                <label for="domain">Enter Domains URL: (One Per Line)</label>
                <textarea class="form-control" rows="10" cols="20" id="domains" placeholder="Domain names" required></textarea>
            </div>
            <div class="form-group">
                <button id="button" class="btn btn-block btn-danger">
                    Get Domains Status
                </button>
            </div>
        </form>
        <div>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>Domain URL</th>
                    <th>Domain Status</th>
                </tr>
                </thead>
                <tbody id="body">

                </tbody>
            </table>
        </div>
        <br><br>
      </div>
</body>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/psl/1.8.0/psl.min.js"></script>
  <script>
      $("#form").submit(function(e){
          e.preventDefault()

          var domains = $('#domains').val().split('\n');

          console.log(domains)

          domains.forEach(domain => {

            var prefix = 'https://';
if (domain.substr(0, prefix.length) !== prefix)
{
    domain = prefix + domain;
}
            
            $.ajax({
              method:"POST",
              url:"/singledomainstatuschecker",
              data:{domain:domain},
              success:function(data){
                  console.log(data.domainstatus)

                  $("#body").append(`
                  <tr>
                     <td>${domain}</td>
                     <td>${data.domainstatus}</td> 
                  </tr>

                  `)
              }
          })
            
          });



      })
  </script>
</html>

 

 

Leave a Reply