Answers for "connect css to flask html"

CSS
10

how to add css in flask app

<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles/mainpage.css') }}">
Posted by: Guest on September-29-2020
0

how to link css to html flask

#link it in html

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

#place a config for your app so that browser doesn't store cashe, if this doesn't update your css clear browser cash for last {x} hours
if __name__ == '__main__':
    app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1
    app.run()

#make sure that your directory looks something like this...
|root|
MainFileWithFlaskProgram.py

	|static|
		|styles|
			styles.css

	|templates|
		YourHTMLFile.html
Posted by: Guest on April-06-2022

Browse Popular Code Answers by Language