FastAPI CLI

0.0.24 · active · verified Sun Mar 29

FastAPI CLI (Command Line Interface) is a command-line program that simplifies running and managing FastAPI applications. It provides commands to serve apps in development and production modes, manage projects, and more. It is usually installed as part of `fastapi[standard]` and receives frequent updates, typically involving dependency bumps and occasional breaking changes related to Python version support or internal dependencies.

Warnings

Install

Imports

Quickstart

Create a `main.py` file with a basic FastAPI application instance named `app`. Then, run the application using `fastapi dev main.py` for development with auto-reload. For more explicit project setup, configure the `entrypoint` in `pyproject.toml` and then simply run `fastapi dev`.

# main.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def read_root():
    return {"message": "Hello FastAPI CLI!"}

# Terminal commands
# Run in development mode (with auto-reload):
# fastapi dev main.py

# Or, for explicit configuration (recommended for larger projects):
# 1. Add to pyproject.toml:
# [tool.fastapi]
# entrypoint = "main:app"
# 2. Then run:
# fastapi dev

view raw JSON →