As a general rule, you probably want to: Run uvicorn --reloadfrom the command line for local development. Run gunicorn -k uvicorn.workers.UvicornWorkerfor production. Additionally run behind Nginx for self-hosted deployments. Finally, run everything behind a CDN for caching support, and serious DDOS protection. Running from the command line¶What is uvicorn and how does it work?
With the advancement of technology, a lightning-fast ASGIserver called Uvicornwas born. However, Uvicornis just a web server without any routing capabilities. Then, Starlettecame along, which provides a complete ASGItoolkit on top an ASGIserver such as Uvicorn, Daphne, or Hypercorn.How to pass uvicorn's config arguments to Gunicorn workers?
gunicorn -w 4 -k uvicorn.workers.UvicornH11Worker Gunicorn provides a different set of configuration options to Uvicorn, so some options such as --limit-concurrencyare not yet supported when running with Gunicorn. If you need to pass uvicorn's config arguments to gunicorn workers then you'll have to subclass UvicornWorker:When should I use flask?
Use Flask if you aren't comfortable with the maturity-level of FastAPI, need to build a full-stack app with server-side templating, or can't live without some of the community-maintained Flask extensions. Like any other Python package, installation is fairly straightforward.