如何使用flask fram打开包含framset的html

2024-03-29 10:03:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我想开门索引.html你说

却找不到图片.html在

我怎么办

在图片.html以及索引.html都在模板中

在索引.html在

  <body>
    <iframe src="pic.html"></iframe>
  </body>

在烧瓶demo.py在

^{pr2}$

Tags: pysrc模板烧瓶demohtml图片body
1条回答
网友
1楼 · 发布于 2024-03-29 10:03:18

Flask不提供templates目录中的文件。您需要为/pic.html设置一个路由,并作为其中的一部分呈现相应的模板:

from flask import Flask,render_template

app = Flask(__name__)


@app.route('/')
def hello_world():
    return render_template("index.html")

@app.route('/pic.html')
def pic():
    return render_template("pic.html")

if __name__ == '__main__':
    app.run()

相关问题 更多 >