flask jinjia2实现html里的iframe标签嵌套

心得

flask和Javaweb不一样Java直接把整个项目部署到了服务器上想用那个页面直接根据路径找就可以只要里面没有什么限制就基本能展示出来,但是flask的页面是靠render_template给渲染出来的你直接根据路径是找不到的,所以要实现页面嵌套我这里给出自己的一种方法,说的有什么不对请大家指正。

演示

@mainScene_bp.route("/hello")
def hello():
    print("hello word!")
    return render_template('6.html')

@mainScene_bp.route("/mainScene")
def mainScene():
    print(url_for("mainScene.mainScene"))
    #obj=render_template('test.html')
    return render_template('mainScene.html')
<div id="imge1">
        <iframe src="http://127.0.0.1:5000/mainScene/hello" width="100%" height="100%" frameborder="0" scrolling="no"></iframe>
    </div>
</div>

其实相当于页面的一个跳转。

猜你喜欢

转载自blog.csdn.net/jiahuiandxuehui/article/details/123700651