You need a static folder where you place images.
A demo.
Folder:
Now i have CSS in html file.
For bigger stuff always have CSS in separate file,
it in also places in static folder.
Eg.
A demo.
Folder:
img_demo\ app.py templates\ index.html static\ images\ back.jpgapp.py:
from flask import Flask, render_template app = Flask(__name__, static_url_path='') @app.route("/") def bak_image(): return render_template("index.html") if __name__ == '__main__': app.run()index.html:
<html> <body> <p>Does the Image Work?</p> <style type="text/css"> body { background: url("{{ url_for('static', filename='images/back.jpg') }}") 0 0 no-repeat; } </style> </body> </html>So this will load "back.jpg" as background image.
Now i have CSS in html file.
For bigger stuff always have CSS in separate file,
it in also places in static folder.
Eg.
static\ css\ style.ccs js\ some_javascript_stuff.js