Async Techniques and Examples in Python Transcripts
Chapter: asyncio-based web frameworks
Lecture: Demo: Converting from Flask to Quart

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Our goal is to convert this working Flask app
0:03 into a Quart app, and it turns out
0:06 because of the very high compatibility between the two APIs
0:09 it's not that much work.
0:11 So let's go over here and add
0:13 take out Flask and put Quart.
0:18 We're going to make sure we pip install those requirements.
0:23 Alright, great, we've got a bunch of things installed here.
0:26 So, how do we do this conversion?
0:28 Well, here's the rough rule of thumb.
0:30 You see the word Flask, you convert
0:32 that to the word Quart.
0:33 If it's lower case, it's lower case quart.
0:35 If it's upper case, upper case Quart.
0:37 Alright, so let's try Quart here.
0:38 And we go over here and we say this .Quart.
0:41 Yeah, looking good. Okay, this file is converted.
0:46 That wasn't so painful, was it?
0:48 With these two views, let's go fix this one.
0:50 We're going to import Quart and we're going to say
0:52 Quart blueprint, that's the kind we want.
0:54 And here we're doing a Flask response
0:57 so we're going to do a Quart response.
0:58 Also we have the city API, similarly
1:01 Flask, Quart, Flask, Quart, Flask abort, Quart abort.
1:06 Flask jsonify, Quart jsonify. You guys get it.
1:10 Am I done? Let's try. Ho ho ho, it is working.
1:14 Seems pretty good, let's try this one.
1:18 Yeah, still working.
1:19 That wasn't too hard, what was this?
1:22 A couple of minutes?
1:23 We've converted from Flask to Quart.
1:25 Granted, larger applications, more find and replace
1:28 but not too bad.