Reputation: 45
I am facing difficulty in accessing CSS and bootstrap files inside HTML within localhost:5000 in flask programming.
I've already tried including the CSS files within static folder but it doesn't work.
<head>
<title>HOME PAGE</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='homestyle.css') }}">
I expect all the CSS modules to be included in the HTML file without any obstacles.
Upvotes: 2
Views: 178
Reputation: 4537
Try this:
<link rel="stylesheet" href="{{ url_for('static', filename='homestyle.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap.css') }}">
Edit: Make sure your folder structure matches the following:
static/
├── homestyle.css
├── bootstrap.css
templates/
├── index.html
app.py
The static folder should be at the root, not inside the templates folder.
Upvotes: 1