I have a problem when rendering template in flask it doesn't recongnize the CSS file but this issue occurs only when I give more than one parameter to the funtion.
for this example the css is working on the page:
@app.route('/test/<usrn>')
def test(usrn):
return render_template('test.html')
but for this one the css isn't working:
@app.route('/test/<usrn>/<grad>')
def test(usrn,grad):
return render_template('test.html')
Strucure of test.html
:
{% extends 'layout.html' %}
{% block body %}
<header>
<div class="container">
<div id="logo">
<a href="{{ url_for('index') }}" id="logo"><img src="../static/images/logo2.png"></a>
</div>
<nav>
<ul>
<li><a href="{{ url_for('index') }}">Dashboard</a></li>
<li><a href="{{ url_for('clasament') }}">Clasament</a></li>
<li><a href="{{ url_for('profil') }}">Profil ({{ uname }})
</a></li>
<li><button onclick="window.location.href='{{ url_for('logout') }}'" class="input_btn1">Log out</button></li>
</ul>
</nav>
</div>
</header>
{% endblock %}
Structure of layout.html
:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="../static/css/main.css?q=1280549780">
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
Directory structure:
- Website
- static
- css
- main.css
- images
- img
- css
- templates
- layout.html
- test.html
- mongo_connect.py
- static