我想在一个屏幕中导入两个表
首先,我将帧分为3帧(上,左,右)
左右框架应该导入csv数据并填写表格。
Py和HTML代码的目录是
web_test\
└app.py
└test.csv
templates\
└index.html
└__init__.py
└dataset1.html
└dataset2.html
└frame1.html
static\
css\
└style.css
我试图像这样生成每个html&py的代码
app.py
from flask import Flask, render_template
import tablib
import os
app = Flask(__name__)
dataset1 = tablib.Dataset()
with open(os.path.join(os.path.dirname(__file__), 'test.csv')) as f:
dataset1.csv = f.read()
dataset2 = tablib.Dataset()
with open(os.path.join(os.path.dirname(__file__), 'test.csv')) as f:
dataset2.csv = f.read()
@app.route("/")
def index():
return render_template('index.html')
@app.route("/dataset1")
def dataset1():
data1= dataset1.html
# return dataset.html
return render_template('dataset1.html', data=data1)
@app.route("/dataset2")
def dataset2():
data2 = dataset2.html
# return dataset.html
return render_template('dataset2.html', data=data2)
if __name__ == "__main__":
app.run()
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<Frameset rows = "17%, 1*" border="0">
<frame src ="../frame1.html" name="frame1" scrolling ="no", marginwidth="0" marginheight="0">
<Frameset cols="30%,*">
<Frame src = "../dataset1.html" name="dataset1" scrolling="no" marginwidth="0" marginheight="0">
<frame src ="../dataset2.html" name="dataset2" scrolling ="no", marginwidth="0" marginheight="0">
</Frameset>
</Frameset>
<BODY>
</BODY>
</html>
dataset1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dataset1</title>
</head>
<body>
<h1>This dataset1</h1>
<div class = "table">
{%block body %}
{{data|safe}}
{% endblock%}
</div>
</body>
</html>
dataset2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dataset2</title>
</head>
<body>
<h1>This dataset2</h1>
<div class = "table">
{%block body %}
{{data|safe}}
{% endblock%}
</div>
</body>
</html>
frame1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
Test
</body>
</html>
但是当我运行这些代码时, 框架正在显示,但其内容不可见 我试图找出哪一个是错的 但是很难找到解决方案
代码是否错误? 或每个代码的目录错误?
我希望有人可以给我建议
预先感谢