烧瓶中未显示背景图像

问题描述 投票:0回答:2

这是我的HTML模板homepage.html中的/home/saurabh/flask/templates

<!DOCTYPE>
<html>
<head>
<title>homepage</title>
<style>
body{
        background-image:url("/home/saurabh/Pictures/599783.jpg");
        background-attachment: fixed;
    }
</style>
</head>
<body>
    <h1>Welcome to our Homepage</h1>
    <h3>We will try to make u happy <strong>YOU</strong></h3>
    <nav>
        <a href="login.html">LOGIN</a>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="signup.html">SIGNUP</a>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="about.html">ABOUT US</a>
    </nav>
</body>
</html>

这是我要在/home/saurabh/flask中的模板上方渲染的python脚本>

from flask import Flask,render_template
app=Flask(__name__)
@app.route('/')
def home():
    return render_template("homepage.html")
if __name__=="__main__":
    app.run(debug=True)

一切正常,但有背景图像。我已经尝试过使用静态目录,但没有任何效果。Web浏览器中未显示背景图片?

这是我的html模板homepage.html,位于/ home / saurabh / flask / templates中

homepage <style>body {background {background-image:url(...]]
html css python-3.x flask
2个回答
0
投票
您需要创建一个目录:/home/saurabh/flask/static

0
投票
您可以从Web服务器而不是烧瓶默认Web服务器为文件调用图像。
© www.soinside.com 2019 - 2024. All rights reserved.