python-3.xframeworksfastapiweb-frameworksuvicorn

What is the purpose of Uvicorn?


I supposed to work with FastAPI. I was taught that FastAPI is used with Uvicorn. What exactly is Uvicorn. I don't know what uvicorn is doing with FastAPI exactly. Can anyone explain?


Solution

  • uvicorn is an ASGI (async server gateway interface) compatible web server. It's (simplified) the binding element that handles the web connections from the browser or api client and then allows FastAPI to serve the actual request.

    uvicorn listens on a socket, receives the connection, does a bit processing and hands the request over to FastAPI, according to the ASGI interface.

    You can read more about what the ASGI specification is, why ASGI was needed and other ASGI implementations on Uvicorn's homepage.