How to Use CSS Javascript and Images With Flask Static Files - Flask Fridays #7

Published: 26 February 2021
on channel: Codemy.com
38,913
809

In this video I'll show you the correct way to use CSS, Javascript, and Images in your Flask app using the Static directory and url_for() tag.


To use CSS, Javascript, and Images in your flask app, you need to create a static directory. Inside that directory, create directories for css, js, and images. Then inside each of those directories, place your css, javascript, and image files.


Then, to access any of those things, use the url_for tag like this:
{{ url_for('static', filename='images/image.png' }}


...as the src for whatever file you're tying to call.


Timecodes
0:00​ - Introduction
1:25 - Create Static Directory
2:28 - Create CSS Stylesheet File
3:49 - Add CSS Static url_for() Tag To Base.html
6:38 - Add Image Static url_for() Tag
7:44 - Create Javascript File
9:06 - Add Javascript Static url_for() Tag
10:12 - Change Javascript CSS Style
11:15 - Conclusion


Watch video How to Use CSS Javascript and Images With Flask Static Files - Flask Fridays #7 online without registration, duration hours minute second in high quality. This video was added by user Codemy.com 26 February 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 38,913 once and liked it 809 people.