简体   繁体   English

将 HTML 条目从 Flask 传递到前端

[英]Passing HTML entry from Flask to front end

So far I have been passing data from Flask to the client using Javascript and DOM.到目前为止,我一直在使用 Javascript 和 DOM 将数据从 Flask 传递给客户端。 I have been looping through all the contents in the array and creating a new DOM element for each.我一直在遍历数组中的所有内容并为每个内容创建一个新的 DOM 元素。

However, I'd like to know if there's any better way to do this.但是,我想知道是否有更好的方法来做到这一点。 I did some googling, but could not find anything useful.我做了一些谷歌搜索,但找不到任何有用的东西。

not much info on this but without knowing anything or what you know or don't know.这方面的信息不多,但不知道任何事情或你知道或不知道的事情。

I haven't used flask but I used django.我没有用过 flask 但我用过 django。

Create an API Using Flask and python at the backend.在后端使用 Flask 和 python 创建 API。

with the API end points you create using flask.使用您使用 flask 创建的 API 端点。

then fetch the data using JavaScript fetch on the front end/client side.然后在前端/客户端使用 JavaScript fetch 获取数据。

hope that helps a little希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM