Answer the question
In order to leave comments, you need to log in
Why is css not showing up in Flask?
Perhaps the question is not difficult, but I couldn’t figure it out on my own.
This is how I have the files:
/server.py
/templates/index.html
-------------/images
----- -------/css/style.css
When I open index.html in the browser, everything is ok, everything is beautiful
I write this in server.py:
from flask import Flask, url_for, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run(port=8080, host='127.0.0.1')
Answer the question
In order to leave comments, you need to log in
Create a static folder and put your css in it.
This is how it should look like:
/server.py
/static/style.css
/templates/index.html
-------------/images
<link rel="stylesheet" href='/static/style.css' />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question