Bottom Page

Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Flask.socketio and client side html tables / JS
#2
Please guys, some help

Below is some of my python code and associated Javascript in html

battling to print tot_cnt, cnt and the data array to a html table.

# app.py
# Background process to update the Delivery data

def background_thread_eft_del():

    while True:
        socketio.sleep(10)
        timeC = time.strftime('%Y/%m/%d %H:%M:%S')

        # Dummy data, to be replaced by Oracle_CX DB queries
        delivery        = {'cnt': 2, 'tot_cnt': 40, 'ds': [['row1',4,9], ['row2',6,2], ['row3',20,98], ['row4',4,9], ['row5',6,0]] }

        delivery_json   = json.dumps(delivery)

        socketio.emit('eft_delivery_update', {'timeC': timeC, 'delivery': delivery_json, 'debug_level': debug_level}, namespace='/eft')


#and the JS code and associated html 
#dashboard.html

[html]
 // Lets update the Delivery table
                socket.on('eft_delivery_update', function(msg) {

                    var timeC               = msg.timeC
                    var debug_level         = msg.debug_level

                    var delivery            = msg.delivery
                    var delivery_cnt        = msg.delivery.cnt
                    var delivery_tot_cnt    = msg.delivery.tot_cnt

                    if (debug_level > 0) {
                        console.log(delivery)
                    }

                    $('#timeC').text( timeC );

                    $('#delivery_cnt').text( delivery_cnt );
                    $('#delivery_tot_cnt').text( delivery_tot_cnt );

                    $('#delivery').append('<tr><td>' + $('<div/>').text( delivery ).html() );

                });

        <table id="EFT_Verticals">
            <th><h2>Delivery: <span id="del_cnt"></span>/<span id="del_tot_cnt"></span></h2></th>
            <th><h2>Load: <span id="load_cnt"></span>/<span id="load_tot_cnt"></span></h2></th>
            <th><h2>Validate: <span id="validate_cnt"></span>/<span id="validate_tot_cnt"></span></h2></th>
            <th><h2>Rec Completed: <span id="rec_compl_tot_cnt"></span></h2></th>
            <tr>
                <td valign="top">
                    <table border="1" id="delivery">
                    </table>
                </td>
                <td valign="top">
[/html]
G
Quote

Top Page

Messages In This Thread
RE: Flask.socketio and client side html tables / JS - by georgelza - Jun-05-2018, 03:56 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  trying to use cgi to get html form data test 3 288 Jul-05-2019, 02:38 PM
Last Post: noisefloor
  Flask and Websockets == True? rxndy 2 330 Apr-21-2019, 04:08 PM
Last Post: rxndy
  How to combine data taken from server between client and GUI? bescf 9 596 Apr-02-2019, 11:48 AM
Last Post: bescf
  Graphql subscriptions client Edoar 0 245 Mar-11-2019, 04:13 PM
Last Post: Edoar
  TCP/IP client script help Rehan11 2 550 Jan-15-2019, 06:48 AM
Last Post: Rehan11
  recive post request from client(browser) python sockets kunz 1 595 Dec-13-2018, 12:53 AM
Last Post: kunz
  tcp server/client port connection issue valshev 2 1,358 Sep-01-2018, 02:50 PM
Last Post: valshev
  Frames above 2000 bytes not acknowledged by client/receiver lukasz139 0 550 Aug-24-2018, 06:34 PM
Last Post: lukasz139
  Send data BMP180 between client and server trought module socket smalhao 0 650 Jul-30-2018, 12:56 PM
Last Post: smalhao
  Sending/Receiving Multiple Message from Server or Client Lyperion 0 799 Jul-30-2018, 07:52 AM
Last Post: Lyperion

Forum Jump:


Users browsing this thread: 1 Guest(s)