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

in #flask3 years ago

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.

✅ Watch The Flask Playlist
https://bit.ly/3ig2eJn

▶️ Get The Code
http://bit.ly/2L1jBl5

✅ Subscribe To My YouTube Channel:
http://bit.ly/2IGzvOR

▶️ See More At:
https://Codemy.com

✅ Join My Facebook Group:
http://bit.ly/2GFmOBz

▶️ Learn to Code at https://Codemy.com
Take $22 off with coupon code: youtube

✅ Buy a Codemy T-Shirt!
http://bit.ly/2VC9WUN