这是我的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>
<a href="signup.html">SIGNUP</a>
<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中
/home/saurabh/flask/static