Async Techniques and Examples in Python Transcripts
Chapter: Course conclusion and review
Lecture: Review: Async Flask

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Another third party library we looked at was Quart.
0:03 Purpose of Quart is take the non-async web framework, Flask
0:07 and make it an async and await-enabled framework.
0:11 It does this by completely reimplementing Flask
0:13 atop asyncio, but doing it in a entirely compatible way
0:17 so even Flask extensions just plug into Quart
0:20 and'll work just fine. So how did that go?
0:22 Well, we added an async method definition here
0:26 so instead of def sun, we have async def sun.
0:29 We do all of our work against as much async operations
0:33 as many async operations as we can, so we make sure we
0:37 await those, and in these places
0:39 our web server can entirely go
0:41 and start processing other requests completely.
0:44 Cause what are we doing?
0:45 We're waiting for that web service, that location service
0:47 or sun service to get back to us.
0:49 So while that's happening, let's do the rest of the work.
0:52 And then, we just return our data, in this case it's an API
0:56 so we're going to return JSON data via quart.jsonify.
0:59 Remember the complex algorithm of conversion here.
1:02 You take the word Flask and you replace
1:04 it with the word Quart.
1:05 If it's lowercase flask it's lowercase quart
1:07 uppercase Flask, uppercase Quart.
1:09 And then you make as much of your libraries
1:11 and your internals async enabled
1:13 and then you just await them and use them, like this.
1:17 It's beautiful.