Visualizing Data via Web Application

The visualization of the incoming data is implemented with a simple index.html and a application.js files, in which the socket communication is written. The .js file includes all required libraries to be able to establish the socket communication, whereas the HTML file reflects what is seen when the 127.0.0.1:5000 URL address is called on the web browser. .js file is responsible for receiving data from the connected channel and then updating the HTML item when a new data is available.

The application.js file can be found under the static/js directory. If you have not downloaded the file from the repository, you can create an empty file with this name and paste the content in listing 2:


$(document).ready(function(){
    //connect to the socket server.
    var socket = io.connect('http://' + document.domain + ':' + location.port + '/test');

    //receive details from server 
    socket.on('newnumber', function(msg) {
        console.log("Received number" + msg.number); arr = msg.number.split(',');

        val = arr[0]; 
        num_of_prod = arr[1];

        $('#val').html(val);
        $('#noo').html(num_of_prod);
    });

});

The index.html file can be found under the templates directory. If you have not downloaded the file from the repository, you can create an empty file with this name and paste the content in listing 3:

HTML-code

This HTML code is available on pastebin: https://pastebin.com/UN8Xwaa7

Open your web browser and call 127.0.0.1:5000 URL address (or alternatively localhost:5000). 

The screen you see should look like this:

image-006