javascript - 加载我的网页后,我想将数据发送到烧瓶中的前端
问题描述
我的页面已加载,但是当在后端处理任务时,路由会更改数据库,因此我想在我的页面上显示这个新的数据库数据,而没有任何用户点击事件(因为他不知道)。因此,就好像用户不知道某个活动的状态,该活动在一段时间后会在后端自动更新,这不知道如何与数据库建立全时连接,或者在更改期间以某种方式向前端发出请求。
@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)
解决方案
推荐阅读
- reactjs - React - 锚标签在 Safari 中不起作用
- vue.js - 在离开组件之前显示有关未保存更改的弹出窗口
- python - 将 excel 文件拆分为数据框,然后在 Python 中从它们创建两个新文件
- reactjs - 如何使用 react-spring 从数组中顺利删除元素?
- html - 字体真棒图标只有在手机/iphone上才有灰色背景
- javascript - 将 django 中的数组的 json 数组传递给 javascript 谷歌图表
- windows - 从文件大小获取磁盘上的文件大小
- swift - 从 Firebase 数据库中检索用户
- javascript - 在 FaunaDB 中更新记录时,如何在不传入每个字段和子对象的情况下更新一个字段?
- android - 使用简单的 checkifUserAlreadyExist php 文件作为基本 URL 时改造 onResponse 不会触发?