Async Techniques and Examples in Python Transcripts
Chapter: asyncio-based web frameworks
Lecture: Demo: An async weather endpoint

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Although I trust you can take the sun example
0:02 and adapt it to the weather example
0:03 let's go ahead and do that together.
0:05 So over here we're going to say we have an async method.
0:09 And again, this right now is a synchronous function.
0:12 Let me just go over here and grab some aiohttp client.
0:17 And we're going to re-implement this again, not request.
0:22 And not response like that but like this.
0:27 And this. Good? One more thing, async.
0:34 Okay, so now this is an async method
0:36 using async with and async await.
0:41 And here, we should be able to go to this function
0:43 and we don't get the data back, we have a coroutine.
0:46 If we await it though, we get the data back.
0:48 Alright, I think that's done it.
0:50 Let's just test the weather as well.
0:54 So there's the sun but if I change that to weather
0:57 yep, also works. So it looks like we've converted from
1:00 an entirely synchronous Flask based API over to Quart
1:04 and what does that take?
1:05 Maybe, maybe 15 minutes, probably less
1:08 with me talking and explaining, poking around.
1:11 If I just put my head down
1:12 that could've been a 10 minute job, easy.
1:15 Granted, pretty toy application
1:17 but not entirely a toy app, right?
1:19 It is calling other services
1:20 it does have some reasonable structure with the blueprints
1:23 and the config files and all that kind of stuff.
1:25 So it's non-trivial
1:27 even if it's somewhat on the small side.
1:29 Hopefully you see this as pretty straight forward
1:31 and pretty easy to do.