From the course: Flask Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Working with static files
- [Instructor] So currently, we have the functionality so that if someone provides a short name, they can get back a URL, if that's what they provided. Now, if they provided a file, well, we don't have that functionality yet. And the reason is we don't know how to serve static files. But let's talk about how we can do that in Flask. So there's a couple of steps here. The first one is we have to create a directory in our project called static. So I'm going to right click here and do new folder. I'm going to name this static, this is a special name that Flask is going to look for whenever you have static files, and any static files that you have, they might be things like JavaScript from your website, you might have CSS, maybe a logo for your website, those are all going to go inside of the static folder. I want to make sure that there's a spot specifically for our users content, things that they have uploaded to us. So inside…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Using redirect and url_for for error handling3m 41s
-
Saving to a JSON file5m 6s
-
Parsing a JSON file for conflicting entries3m 11s
-
Alerting users with message flashing5m 26s
-
File uploads from users8m 17s
-
Variable rules in URLs5m 39s
-
Working with static files4m 19s
-
Displaying custom error pages5m 49s
-
-
-
-