FastAPI 0.115 cheatsheet
FastAPI 0.115: Running the app
6 common FastAPI 0.115 tasks.
Start the development server
Run the app with auto-reload. It listens on 127.0.0.1:8000 by default.
fastapi dev main.py
Change the host and port
Listen on all interfaces on port 8080, for example inside a container or on a LAN.
fastapi dev main.py --host 0.0.0.0 --port 8080
Caution: Binding to 0.0.0.0 exposes the development server to your network.
Start the production server
Run without auto-reload, listening on 0.0.0.0 by default.
fastapi run main.py
Run several worker processes
Start multiple processes to use more than one CPU core.
fastapi run main.py --workers 4
Run with Uvicorn directly
Start the app object named app in main.py with auto-reload.
uvicorn main:app --reload
Fetch the OpenAPI schema
Download the JSON schema FastAPI generates. The interactive docs are served at /docs.
curl http://127.0.0.1:8000/openapi.json