After my webpage is loaded i want to send data to frontend in flask

Viewed 99

My page is loaded but when tasks are handled in the backend the route changes the database so I want to display this new database data on my page, without any user on click event(as he is not aware). So it's like the user does not know about the status of an activity that gets updated in the backend automatically after some time which is unknown how do I make an all-time connection with the database or somehow during change make a request to the frontend.

@app.route("/orders", methods= ["GET", "POST"])
@login_required
def orders():   
    stratergy = Stratergy.query.all()
    post1 = request.args.get('post')
    strat_id = request.args.get('id')
    strat_unique_key = request.args.get('uniquekey')
    strat_signal =request.args.get('signal')
    if(strat_id!=None):
        strat_s = Stratergy.query.get(strat_id)
        if(strat_s.unique_key == strat_unique_key and strat_s.Stratergy_stage == "0"):
            strat_s.Stratergy_stage = str(strat_signal)
            db.session.commit()
            #send this update message to frontend 
        else:
            print("no")
    return render_template('orders.html' , v=0 , stratergy=stratergy)
0 Answers
Related