首页 > 解决方案 > 加载我的网页后,我想将数据发送到烧瓶中的前端

问题描述

我的页面已加载,但是当在后端处理任务时,路由会更改数据库,因此我想在我的页面上显示这个新的数据库数据,而没有任何用户点击事件(因为他不知道)。因此,就好像用户不知道某个活动的状态,该活动在一段时间后会在后端自动更新,这不知道如何与数据库建立全时连接,或者在更改期间以某种方式向前端发出请求。

@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)

标签: javascriptpythonajaxflaskwebhooks

解决方案


推荐阅读