将 webix 与烧瓶一起使用

Using webix with flask

我正在尝试了解 webix 框架并将其与我的 Flask 应用程序一起使用。所有文档都涉及 html 文件中的静态数据或 php 示例。

填充数据表的简单 html 文件如下所示(根据 文档

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../static/css/webix.css" type="text/css" charset="utf-8">
    <script src="../static/js/webix.js" type="text/javascript" charset="utf-8"></script>
    <title>Webix Test 4</title>
</head>
<body>
    <script>
      webix.ui({
          id:"dtable",
          view:"datatable",
          url:"/gettabledata"
      });
    </script>
</body>
</html>

在我的 Flask 路由器中,我完成了以下操作(来自教程):-

peopleData = {'data':[
    {'title': "01. Basique", 'duration': "3:38"},
    {'title': "02. Moon", 'duration': "3:47"},
    {'title': "03. Unsaid", 'duration': "3:48"},
    {'title': "04. Eitheror", 'duration': "5:45"},
    {'title': "05. Above the Clouds", 'duration': "3:50"}]}
return jsonify(peopleData)

网页没有任何显示。

我在尝试了解如何使用 python 和 flask 加载变量(例如页面标题)时遇到了类似的问题。

很明显,我遗漏了一些关于 webix 如何与 python/flask 一起工作的基础知识。 (嵌入数据的页面工作正常,没有问题)

首先你需要在不使用 Flask 的情况下尝试一下

index.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css" charset="utf-8">
    <script src="http://cdn.webix.com/edge/webix.js" type="text/javascript" charset="utf-8"></script>
    <title>Webix Test 4</title>
</head>
<body>
    <script>
webix.ui({
    rows: [{
        view: "template",
        type: "header",
        template: "My App!"
        }, {
            view: "datatable",
            autoConfig: true,
            editable: true,
            data: [
        {'title': "01. Basique", 'duration': "3:38"},
        {'title': "02. Moon", 'duration': "3:47"},
        {'title': "03. Unsaid", 'duration': "3:48"},
        {'title': "04. Eitheror", 'duration': "5:45"},
        {'title': "05. Above the Clouds", 'duration': "3:50"}]
        }]
    });
    </script>
</body>
</html>

python3 -m http.server 9004

jsfiddle

然后用 Flask 试试

<script>
var my_data =  webix.ajax().get("http://localhost:9004/my_route");
webix.ui({
    rows: [{
        view: "template",
        type: "header",
        template: "My App!"
        }, {
            view: "datatable",
            autoConfig: true,
            editable: true,
            data: my_data
        }]
    });
    </script>