Reputation: 135
I'm newbie to the Flask, and I have problem dealing with linking static files, though I'm following all the tutorials exactly.
following is my folder tree
-env
-static
-css
-main.css
-js
-templates
-base.html
-index.html
-app.py
following is the code inside.
----app.py
---
from flask import Flask, render_template, url_for
app = Flask(__name__, static_folder="static")
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)
-----base.html
-------
'''
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}">
{% block head %}{% endblock %}
</head>
<body>
fuck yeh
{% block body %}{% endblock %}
</body>
</html>
----index.html------
{% extends 'base.html' %}
{% block head %}
{% endblock %}
{% block body %}
<h1>Template fuck</h1>
{% endblock %}
-----main.css
-----
body{
margin : 0;
padding : 0;
background : blue;
font-family: sans-serif
}
'''
and now these are problems.
main.css
, it shows green.
And though you remove 'import url_for' from app.py
, it insist green.
When you remove 'import url_for', it's supposed not to check the base.html, thus the background should turn white. but it insist damn green!Green was the first color for test, but doesn't follow up next changes. What's wrong with my Flask?
Upvotes: 0
Views: 78