Python Web Apps that Fly with CDNs Transcripts
Chapter: Integrating Static Content
Lecture: First CDN url
0:00 It looks like this URL pull zone is working for our web app through ngrok back into the Flask development server running in PyCharm.
0:11 How insane is that? But we're ready to go and actually start adding the CDN aspects, the CDN URLs to our static content.
0:21 So let's jump over here and open up. Let's first go to the homepage here because in here we've got our content for our image.
0:32 So when we see /static /image /categories, so like over here, /static /image /categories, and then we have this Apple Webp,
0:45 that's the category icon up here. We need to add this, this prefix to it. So we're gonna come over here and for now, just put this.
1:00 We're gonna run into some issues with it in the future, but for now, we're just gonna put that there.
1:05 Here's one thing that's really important about this web app, it doesn't auto reload the views. So in order for this to take effect,
1:13 be sure you shut it down and start it up again. Not ngrok, just the web server for the Python code. Okay, so now let me put ngrok in the back here
1:23 and I'll put this over to the side. So if we refresh this page, it's going to need to go and find all those images at the CDN location.
1:33 And when it does that, it says, well, that's a URL zone. So we're going to come back and ask the server, it's at ngrok, which is going to route its
1:39 way back. So you should see these requests start showing up over here. Look at that. Here they come. And you see them rolling in nice and slowly.
1:50 That was slow, wasn't it? All those pages. It was slow because it was slow for us before. It's also slow for the CDN to load it.
1:58 But now if we load it again, boom. We go back over to search. We come back. Wham, look how fast that is. Because where are these coming from?
2:10 Let's do a different one this time. Image, open a new tab. Look at that, it comes out of the CDN. And I can load it again and again and super fast.
2:21 Cool, right? So that was easy. All we have to do now is find everywhere else where we were doing some /static /something
2:29 in our website and upgrade that.