Flask background-image not showing
<p>My background-image works only for this template that has @app.route('/').</p>

<pre><code> &lt;header class="intro-header" style="background-image: url('static/img/home.jpg')"&gt;
</code></pre>

<p>This works perfectly fine when:</p>

<pre><code>@app.route('/')
def home():
    return render_template('post.html')
</code></pre>

<p>Everything works. I get this:</p>

<pre><code>127.0.0.1 - - [19/Sep/2016 21:07:11] "GET /static/img/home.jpg HTTP/1.1" 304 
</code></pre>

<p>But when I use same template with:</p>

<pre><code>@app.route('/post/')
def post():
     return render_template('post.html')
</code></pre>

<p>I get this:</p>

<pre><code>127.0.0.1 - - [19/Sep/2016 21:15:23] "GET /post/static/img/home.jpg HTTP/1.1" 404 -                                                                          
</code></pre>

<p>And background-image is blank.</p>

<blockquote>
  <p>Partial URLs are interpreted relative to the source of the style sheet, not relative to the document - <a href="https://www.w3.org/TR/REC-CSS1/#url" rel="nofollow">w3 CSS</a> </p>
</blockquote>

<p>This means that you need to change your <code>url()</code> a bit, to include the leading <code>/</code>. </p>

<pre><code>"background-image: url('/static/img/home.jpg')"
</code></pre>

python html css flask