Answer the question
In order to leave comments, you need to log in
Why can't the css file find the image (flask)?
I got the following project structure:
main.py
templates/index.html
static/style/style.css
______/img/bg.jpg Main.py
code:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href='../static/style/style.css' />
</head>
<body>
</body>
</html>
body {
background-image: url(../img/bg.jpg) repeat;
}
Answer the question
In order to leave comments, you need to log in
You need to correctly set the address to the picture, it looks for the picture in the style folder, and not in the root of the project.
../../../ will help
<link rel="icon" type="image/png" href="/static/images/icons/favicon.ico"/>
body {
background-image: url(/img/bg.jpg) repeat;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question