Flask jinjia2は、htmlでiframeタグのネストを実装します

経験

FlaskはJavawebとは異なり、Javaはプロジェクト全体をサーバーに直接デプロイします。そのページを使用してパスに従って直接プロジェクトを検索する場合は、制限がない限り、基本的に表示できます。ただし、フラスコのページは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