• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

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

武飞扬头像
肥学
帮助1

心得

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>


用url_for()也可以道理都是一样的

<div id="imge1">
            <iframe src="{{url_for('mainScene.scene6')}}" width="100%" height="100%" frameborder="0"
                    scrolling="no"></iframe>
        </div>

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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhggfaka
系列文章
更多 icon
同类精品
更多 icon
继续加载