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 into a Quart app, and it turns out because of the very high compatibility between the two APIs
0:10 it's not that much work. So let's go over here and add take out Flask and put Quart. We're going to make sure we pip install those requirements.
0:24 Alright, great, we've got a bunch of things installed here. So, how do we do this conversion? Well, here's the rough rule of thumb.
0:31 You see the word Flask, you convert that to the word Quart. If it's lower case, it's lower case quart. If it's upper case, upper case Quart.
0:38 Alright, so let's try Quart here. And we go over here and we say this .Quart. Yeah, looking good. Okay, this file is converted.
0:47 That wasn't so painful, was it? With these two views, let's go fix this one. We're going to import Quart and we're going to say
0:53 Quart blueprint, that's the kind we want. And here we're doing a Flask response so we're going to do a Quart response.
0:59 Also we have the city API, similarly Flask, Quart, Flask, Quart, Flask abort, Quart abort. Flask jsonify, Quart jsonify. You guys get it.
1:11 Am I done? Let's try. Ho ho ho, it is working. Seems pretty good, let's try this one. Yeah, still working. That wasn't too hard, what was this?
1:23 A couple of minutes? We've converted from Flask to Quart. Granted, larger applications, more find and replace but not too bad.

Talk Python's Mastodon Michael Kennedy's Mastodon