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

in #flask2 months 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

Coin Marketplace

STEEM 1.20
TRX 0.13
JST 0.141
BTC 60752.79
ETH 2160.86
BNB 543.96
SBD 8.84