fastapi-dev - Man Page

fastapi dev – Run a FastAPI app in development mode.

Synopsis

fastapi dev [Options] [PATH]

Description

This is equivalent to fastapi-run(1) but with reload enabled and listening on the 127.0.0.1 address.

It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

If no path is passed, it tries with:

It also detects the directory that needs to be added to the PYTHONPATH to make the app importable and adds it.

It detects the FastAPI app object to use. By default it looks in the module or package for an object named:

Otherwise, it uses the first FastAPI app found in the imported module or package.

Options

--host TEXT

The host to serve on. For local development in localhost use 127.0.0.1. To enable public access, e.g. in a container, use all the IP addresses available with 0.0.0.0. [default: 127.0.0.1]

--port INTEGER

The port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port 443 and HTTP on port 80, transferring the communication to your app. [default: 8000]

--reload,  --no-reload

Enable auto-reload of the server when (code) files change. This is resource intensive, use it only during development. [default: reload]

--root-path TEXT

The root path is used to tell your app that it is being served to the outside world with some path prefix set up in some termination proxy or similar.

--app TEXT

The name of the variable that contains the FastAPI app in the imported module or package. If not provided, it is detected automatically. [default: None]

--proxy-headers,  --no-proxy-headers

Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info. [default: proxy-headers] --help Show a help message and exit.

Arguments

PATH

A path to a Python file or package directory (with __init__.py files) containing a FastAPI app. If not provided, a default set of paths will be tried. [default: None]

See Also

fastapi-run(1)

fastapi(1)

Referenced By

fastapi(1), fastapi-run(1).

May 2024