new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

FastAPI · all subjects

deployment

15 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

FastAPI development server command

The fastapi dev command automatically reads the main.py file, detects the FastAPI app, and starts a development server using Uvicorn with auto-reload enabled by default.

FastAPI standard dependencies installation

Installing with uv add "fastapi[standard]" includes: email-validator (Pydantic), httpx (required for TestClient), jinja2 (for default template configuration), python-multipart (for form parsing with request.form()), uvicorn (for the server), and fastapi-cli[standard] (for the fastapi command).

fastapi run command for production

Use `fastapi run` to run FastAPI in production mode. Autoreload is disabled by default and it listens on 0.0.0.0 (all available IP addresses), making it publicly accessible.

FastAPI CLI uses Uvicorn

FastAPI CLI internally uses Uvicorn, a production-ready ASGI server, to run applications.

FastAPI CLI app detection defaults

FastAPI CLI automatically detects the FastAPI app to run, assuming it is an object named `app` in a file named `main.py` or similar variants.

Configure app entrypoint in pyproject.toml

Configure the app location in pyproject.toml using `[tool.fastapi]` section with `entrypoint = "module:app"` format. For example, `entrypoint = "main:app"` translates to `from main import app`, and `entrypoint = "backend.main:app"` translates to `from backend.main import app`.

fastapi dev with explicit path

Pass a file path to `fastapi dev` to specify the app location. For example: `uv run fastapi dev main.py`.

FastAPI CLI installation

FastAPI CLI is installed automatically when you add FastAPI to your project, for example with `uv add "fastapi[standard]"`.

Recommendation to use pyproject.toml for entrypoint

It is recommended to configure the entrypoint in pyproject.toml rather than passing it via CLI options each time, as this allows tools like VS Code Extension and FastAPI Cloud to discover the app configuration.

fastapi dev autoreload and stability

Autoreload is enabled by default in `fastapi dev`. It automatically reloads the server when code changes, but is resource-intensive and less stable than with autoreload disabled. Use it only for development.

fastapi run autoreload disabled

`fastapi run` has autoreload disabled by default for production stability.

fastapi run listens on 0.0.0.0

`fastapi run` listens on 0.0.0.0 by default, which means all available IP addresses, making it publicly accessible to anyone who can communicate with the machine. This is typical for production deployment in containers.

HTTPS and SSL in production deployment

In most production cases, you should use a terminating proxy to manage HTTPS for you. This depends on how you deploy your application—your provider may handle it or you must set it up yourself.

fastapi dev with --entrypoint option

Use the `--entrypoint` option with `fastapi dev` to specify the app entrypoint. For example: `uv run fastapi dev --entrypoint main:app`.

fastapi dev command for development

Use `fastapi dev` to run your FastAPI app for development. It starts the development server with autoreload enabled by default and listens on 127.0.0.1 (localhost only).

Give your agent this brain