Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by pythonhosted.org #
 
PREVIOUS NEXT
Tagged: #link #css #html #flask
ADD COMMENT
Topic
Name
5+9 =