【发布时间】:2020-01-16 03:59:35
【问题描述】:
我可以使用烧瓶浏览到我的主页 index.html 页面,但是当我单击索引页面上的按钮时,页面被定向到 mytopo.html 页面,但没有出现拓扑视图并出现错误。尝试转到 mytopo.html 页面时出现以下错误。似乎找不到我的 json 文件(mytopo.json)
192.168.56.1 - - [16/Jan/2020 11:31:15] "GET /mytopo HTTP/1.1" 200 -
192.168.56.1 - - [16/Jan/2020 11:31:15] "GET /mytopo.json HTTP/1.1" 404 -
这是flask项目的结构
mywebfolder
myapp.py --- main file and run server
static --- for images
image1.jpg
templates --- all html files are here
index.html
mytopo.html
data --- my json file is store here
mytopo.json
myapp.py
app = Flask(__name__)
#Function for index page
@app.route('/')
def startPage():
bodyText=Markup("<b>MAIN PAGE</b>")
return render_template('index.html', bodyText=bodyText)
#topology view
@app.route('/mytopo')
def mytopo():
return render_template("mytopo.html")
index.html
<button style="width:10px;height:10px"><font size="6"><a href="mytopo">Topology View</a></font></button>
mytopo.html是使用vis.js和json文件(mytopo.json)查看拓扑
var json = $.getJSON("mytopo.json")
.done(function(data){
var data = {
nodes: data.nodes,
edges: data.edges
};
var network = new vis.Network(container, data, options);
});
var container = document.getElementById('mynetwork');
</script>
我真的很感激有人能带我走……请帮忙,谢谢。
【问题讨论】:
标签: python html json flask vis.js