Bottom Page

Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Flask.socketio and client side html tables / JS
Hi all

I have a very server side long polling application atm that I'm trying to modify to be more client/server using flask_socketio with client side JS.

The application displays data in html tables. and then refresh every 10-15 seconds.

The server side I have enough knowledge how to get working...

Any chance someone have a example of using socketio pushing a JSON payload or even basic Python dictionary object and then displaying it using JS on the client / in a table layout... JS is skill level 0 at the moment for me still.

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.

# Background process to update the Delivery data

def background_thread_eft_del():

    while True:
        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 

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

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

                    var delivery            =
                    var delivery_cnt        =
                    var delivery_tot_cnt    =

                    if (debug_level > 0) {

                    $('#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>
                <td valign="top">
                    <table border="1" id="delivery">
                <td valign="top">

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  trying to use cgi to get html form data test 3 284 Jul-05-2019, 02:38 PM
Last Post: noisefloor
  Flask and Websockets == True? rxndy 2 329 Apr-21-2019, 04:08 PM
Last Post: rxndy
  How to combine data taken from server between client and GUI? bescf 9 592 Apr-02-2019, 11:48 AM
Last Post: bescf
  Graphql subscriptions client Edoar 0 244 Mar-11-2019, 04:13 PM
Last Post: Edoar
  TCP/IP client script help Rehan11 2 548 Jan-15-2019, 06:48 AM
Last Post: Rehan11
  recive post request from client(browser) python sockets kunz 1 593 Dec-13-2018, 12:53 AM
Last Post: kunz
  tcp server/client port connection issue valshev 2 1,349 Sep-01-2018, 02:50 PM
Last Post: valshev
  Frames above 2000 bytes not acknowledged by client/receiver lukasz139 0 548 Aug-24-2018, 06:34 PM
Last Post: lukasz139
  Send data BMP180 between client and server trought module socket smalhao 0 648 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)