flask css code example

Example 1: flask link stylesheet

<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">

Example 2: how to add css in flask app

<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles/mainpage.css') }}">

Example 3: css and js on flask

<!-- Put in HTML file--> 

<!-- 
JS
parent_dir is reletive to Flask app.py dir
meaning: /main/app.py
		 /main/parent_dir/file.js
-->
<script src="{{url_for('parent_dir', filename='file.js')}}"></script>

<!-- 
CSS
parent_dir is reletive to Flask app.py dir
meaning: /main/app.py
		 /main/parent_dir/file.css
-->
        <link href="{{ url_for("parent_dir",filename="file.css")  }}" rel="stylesheet">