My problem is that the CSS is not loaded correctly when I run the app. The CSS only refreshes when I restart my computer.... this does not make any sense to me. I even tried different connecting ways( Full path, relative path, let flask create the path...)
Here is my code:
import flask
app = flask.Flask(__name__)
def get_latest_packages():
return [
{'name': 'flask','version': '1.2.3'},
{'name': 'sqlalchemy', 'version': '2.2.0'},
{'name': 'passlib', 'version': '3.0.0'}
]
@app.route('/')
def index():
test_packages = get_latest_packages()
return flask.render_template('index.html', packages = test_packages)
@app.route('/about')
def about():
return flask.render_template('about.html')
if __name__ == '__main__':
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Python Package Index Demo</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="/static/css/site.css"/>
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
<div class="main_content">
<h1>Python Packages Index</h1>
<h2>Packages</h2>
{% for p in packages %}
<div>
<span class="title">
{{ p.name.upper() }}
</span>
<span class="version">
{{ p.version }}
</span>
</div>
{% endfor %}
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

F5maybe together withShiftorCtrl. If that does not help open the CSS file in your browser directly and pressF5. Don't forget to restart flask and make sure all flask processes have been stopped.