python烧瓶应用程序未显示我在html文件中制作的pdf文件容器

发布于 2025-02-02 13:11:48 字数 2318 浏览 2 评论 0原文

我有一个带有以下代码的HTML文件,该文件显示网页上的嵌入PDF文件。在运行app.py时,网页显示良好,但未显示PDF。我也尝试将文件添加到静态文件夹中,但不起作用。有人可以在这里帮我吗?谢谢!

html 标记:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>display pdf on webpage</title>

   <!--This will align our textboxes and labels-->
    <style type="text/css">
                label{
                    width: 100px;
                    display:inline-block;}>

        .container{padding: 30px;}
    </style>
    <style>
        body
        {
        background-image: url({{url_for('static',filename='bg_image.jpg')}});
          background-attachment: fixed;
          background-size: cover;
          }
    </style>
</head>
<body>
<!--Title-->
<h2 align="center">Title</h2>
<h3 align="center" style="position:relative; bottom:15px;">Please select your Data </h3>

<!--Label and input-->
<label style="position:relative; left:5px; bottom:15px;"> Data 1:</label>
        <input name ="data1"  type="text" style="position:relative; bottom:15px;">
<label style="position:relative; left:10px; bottom:15px;"> Data 2:</label>
        <input name ="data 2" type="text" style="position:relative; bottom:15px;">
<label style="position:relative; left:10px; bottom:15px;"> date:</label>
        <input name ="date" type="date" style="position:relative; bottom:15px;">

<!--Buttons:-->
<input style="position:relative; bottom:15px; left:20px;" type="submit" value="Generate"/>
<input style="position:relative; bottom:15px; left:20px;" type="reset" value="reset" />
<p></p>

<!--pdf container-->
 <div
         class = "container" style="position:relative; bottom:20px">
        <embed src = "\location\filename.pdf" type="application/pdf" width = "100%" height = "590px" />
      
 </div>

</body>
</html>

app.py

from flask import Flask, render_template, request


app = Flask(__name__)


@app.route("/", methods=["GET", "POST"])
def main():

    return render_template("html_code.html")


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

I have a html file with below code which is displays an embed pdf file on webpage. while running the app.py, webpage is displaying just fine but pdf is not displayed. I tried adding file to static folder as well but didn't work. can someone help me out here? Thanks!

HTML markup:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>display pdf on webpage</title>

   <!--This will align our textboxes and labels-->
    <style type="text/css">
                label{
                    width: 100px;
                    display:inline-block;}>

        .container{padding: 30px;}
    </style>
    <style>
        body
        {
        background-image: url({{url_for('static',filename='bg_image.jpg')}});
          background-attachment: fixed;
          background-size: cover;
          }
    </style>
</head>
<body>
<!--Title-->
<h2 align="center">Title</h2>
<h3 align="center" style="position:relative; bottom:15px;">Please select your Data </h3>

<!--Label and input-->
<label style="position:relative; left:5px; bottom:15px;"> Data 1:</label>
        <input name ="data1"  type="text" style="position:relative; bottom:15px;">
<label style="position:relative; left:10px; bottom:15px;"> Data 2:</label>
        <input name ="data 2" type="text" style="position:relative; bottom:15px;">
<label style="position:relative; left:10px; bottom:15px;"> date:</label>
        <input name ="date" type="date" style="position:relative; bottom:15px;">

<!--Buttons:-->
<input style="position:relative; bottom:15px; left:20px;" type="submit" value="Generate"/>
<input style="position:relative; bottom:15px; left:20px;" type="reset" value="reset" />
<p></p>

<!--pdf container-->
 <div
         class = "container" style="position:relative; bottom:20px">
        <embed src = "\location\filename.pdf" type="application/pdf" width = "100%" height = "590px" />
      
 </div>

</body>
</html>

app.py:

from flask import Flask, render_template, request


app = Flask(__name__)


@app.route("/", methods=["GET", "POST"])
def main():

    return render_template("html_code.html")


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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文