Deploying the application to Uvicorn
Uvicorn is a popular ASGI-based HTTP server that’s used by the Starlette and FastAPI frameworks. But Uvicorn remains an easy-to-use ASGI development server. It is still ideal to deploy Flask[async] or FastAPI applications to the production server using Gunicorn with uvicorn.workers.UvicornWorker as its HTTP server.
Even though Gunicorn is a WSGI-based server, it can support running Flask applications in standard and async mode through its --worker-class setting. For Flask[async] applications, Gunicorn can utilize the aiohttp or uvicorn worker class types.
Our async Online Grocery application (ch11-async) uses Gunicorn with a uvicorn worker as its deployment platform. Before applying the worker type, install the uvicorn module first by running the following pip command:
pip install uvicorn
Then, import WsgiToAsgi from the uvicorn module’s asgiref.wsgi module to wrap the Flask app instance. The following snippet shows how...