flask 前端(html)与后端(python)相互传数据

1.后端如何得到前端数据
1)如果前端提交的方法为POST:
后端接收时要写methods=[‘GET’,‘POST’]
xx=request.form.get(xx);
xx=request.form[’‘xx’]
2)如果是GET
xx=request.args.get(xx)
2.后端向前端传数据

  1. 传单个数据`
    return render_template(‘需要传参网址’,xx=u’ xx’);
    前端接收:
  2. 传多个数据
    先把数据写进字典,字典整体传
    return render_template(‘需要传参网址’,**字典名’);
    前端接收:
posted @ 2021-02-26 20:00  zae  阅读(2955)  评论(0编辑  收藏  举报