Choosing Quart over Flask 2.x
Quart is a Flask framework in and out but with a platform that runs entirely on asyncio
. Many of the core features from Flask are part of the Quart framework, except for the main application class. The framework has its Quart
class to set up an application.
Moreover, Quart supports the HTTP/2 protocol, which allows faster interaction between its components and the server. Therefore, it is best to use servers such as the hypercorn
server, which supports HTTP/2 request-response transactions.
Since Quart and Flask are almost the same, migration of Flask applications to Quart is seamless and straightforward. ch05-quart
is a product of migrating our ch05-web
and ch05-api
projects into using the Quart platform. The following is the app/__init__.py
configuration of that project:
from quart import Quart import toml from app.model.config import init_db from app.api.home import home, welcome from app.api.login import add_login, list_all_login def create_app...