No initialization needed
main.py
python script with basic route# main.py from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"}
uvicorn
uvicorn
is a ASGI
server (Asynchronous Server Gateway Interface)
ASGI
is a specification for asynchronous web servers and applications in Pythonpip install uvicorn uvicorn <app_name>:app --reload
FastAPI comes with Swagger UI for documentation
http://localhost:8000/docs
from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, query_param: str = None): return {"item_id": item_id, "query_param": query_param}