FastAPI walk through

FastAPI is a modern, high-performance Python framework used to build REST APIs, backend services, microservices, and AI/LLM applications.

Uvicorn is an ASGI web server used to run FastAPI applications.

An ASGI (Asynchronous Server Gateway Interface) web server is software that runs asynchronous Python web applications and acts as a bridge between network protocols and Python code. It is the modern successor to WSGI (Web Server Gateway Interface), built to handle high concurrency, real-time traffic, and long-lived connections like WebSockets

  • FastAPI – Your Python web application/framework.
  • Uvicorn – The server that runs your application and handles incoming HTTP connections.
  • Pydantic – Validates incoming and outgoing data.

  • Flask → WSGI → Gunicorn
  • FastAPI → ASGI → Uvicorn

uv add "fastapi[standard]"
vim main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}

uv run fastapi dev main.py
warning: `VIRTUAL_ENV=venv` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
⚡️ Starting FastAPI in development mode
🐍 Using import string: main:app
🌐 Server started at http://127.0.0.1:8000
Documentation at http://127.0.0.1:8000/docs
Logs:
▕ Will watch for changes in these directories: ['/Users/mshaik/fastapi-notes']
▕ Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
▕ Started reloader process [5006] using WatchFiles
▕ Started server process [5008]
▕ Waiting for application startup.
▕ Application startup complete.
http://127.0.0.1:8000/docs
http://127.0.0.1:8000/redoc

Leave a Reply