I’m getting this error but my files do exist and I think my file structure is correct, I don’t know what to do due to I’ve tried everything I’ve found on the net but it’s still failing to load the css to my html base template.
This is my structure:
C:.
│ run.py
│
├───instance
│ site.db
│
├───jecco
│ models.py
│ routes.py
│ __init__.py
│
├───static
│ style.css
│
└───templates
base.html
This is my base.html:
<!doctype html>
<html lang="es">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<title>MyProject</title>
</head>
<body>
<header class="header">
<div>
<h1>Welcome</h1>
<a href="{{ url_for('main.home')}}">Inicio</a>
<a href="">Catalogo</a>
<a href="">Rendimiento</a>
<hr>
</div>
</header>
<h1>Hello, world!</h1>
</body>
This is my css file:
.header{
background-color: blueviolet;
display: grid;
grid-template-columns: 1fr 2fr;
}
I’ve tried moving my files to the same folders as the templates, with a styles folder instead of static and using relative and absolute paths.
4
I’ve already found a way to solve this with this line of code:
app = Flask(__name__, template_folder="../templates", static_folder="../static")
after setting the static folder it worked, but remember! use the 2 points before the slash or it won’t work.
1