Flask - Store feedback data to server

最后都变了- 提交于 2019-12-02 03:25:40

I think you have to use the Ajax Request in javascript. You can do it with Jquery (which is pretty easy) or in classic javascript.

Edit : You can find some docs on google !

Small exemple :

$.ajax({
  type     : 'POST',
  url      : '/path_url',
  dataType : "json",
  contentType: 'application/json;charset=UTF-8',
  data     : JSON.stringify(dict_var),
  success : function (result) {
    console.log(result)
  },
  error : function (error) {
    console.log(error);
  }
});

With dict_var which is a dictionnary, you just need to recover data from your form (pretty simple) and send it through dictionnary.

And in flask, you just need to read data in your route:

data = json.loads(request.data)
tmp = data["key"]

Peace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!