Skip to content

5.2 Web Server

FastAPI does not have its own web server built-in, but it is designed to run on ASGI servers (Asynchronous Server Gateway Interface), primarily:

ServerDescription
UvicornMost commonly used. Lightweight and fast.
HypercornAlternative ASGI server. Supports HTTP/2, QUIC.
DaphnePart of Django Channels (less common for FastAPI).

You install and run Uvicorn like this:

Terminal window
pip install uvicorn
uvicorn main:app --reload
  • main → your Python file (i.e., main.py)
  • app → the FastAPI instance (app = FastAPI())
  • --reload → auto-reload when code changes (for dev only)

FastAPI is:

  • Just a Python framework to define routes and logic.
  • ASGI-compatible (similar to how Flask is WSGI-compatible).
  • Dependent on an external ASGI server like Uvicorn to actually serve HTTP requests.