]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✨ Add FastAPI CLI, the new `fastapi` command (#11522)
authorSebastián Ramírez <tiangolo@gmail.com>
Thu, 2 May 2024 22:37:31 +0000 (15:37 -0700)
committerGitHub <noreply@github.com>
Thu, 2 May 2024 22:37:31 +0000 (15:37 -0700)
18 files changed:
README.md
docs/en/docs/advanced/behind-a-proxy.md
docs/en/docs/advanced/openapi-callbacks.md
docs/en/docs/advanced/openapi-webhooks.md
docs/en/docs/advanced/settings.md
docs/en/docs/advanced/websockets.md
docs/en/docs/advanced/wsgi.md
docs/en/docs/css/termynal.css
docs/en/docs/deployment/concepts.md
docs/en/docs/deployment/docker.md
docs/en/docs/deployment/manually.md
docs/en/docs/fastapi-cli.md [new file with mode: 0644]
docs/en/docs/features.md
docs/en/docs/index.md
docs/en/docs/tutorial/first-steps.md
docs/en/docs/tutorial/index.md
docs/en/mkdocs.yml
pyproject.toml

index c7adc49cdffabc02f1572ccec40ff20900b340fb..1db8a8949e13b1aed04ef4656308b743e3789962 100644 (file)
--- a/README.md
+++ b/README.md
@@ -139,18 +139,6 @@ $ pip install fastapi
 
 </div>
 
-You will also need an ASGI server, for production such as <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a> or <a href="https://github.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>.
-
-<div class="termy">
-
-```console
-$ pip install "uvicorn[standard]"
-
----> 100%
-```
-
-</div>
-
 ## Example
 
 ### Create it
@@ -211,11 +199,24 @@ Run the server with:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
-
+$ fastapi dev main.py
+
+ ╭────────── FastAPI CLI - Development mode ───────────╮
+ │                                                     │
+ │  Serving at: http://127.0.0.1:8000                  │
+ │                                                     │
+ │  API docs: http://127.0.0.1:8000/docs               │
+ │                                                     │
+ │  Running in development mode, for production use:   │
+ │                                                     │
+ │  fastapi run                                        │
+ │                                                     │
+ ╰─────────────────────────────────────────────────────╯
+
+INFO:     Will watch for changes in these directories: ['/home/user/code/awesomeapp']
 INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-INFO:     Started reloader process [28720]
-INFO:     Started server process [28722]
+INFO:     Started reloader process [2248755] using WatchFiles
+INFO:     Started server process [2248757]
 INFO:     Waiting for application startup.
 INFO:     Application startup complete.
 ```
@@ -223,13 +224,13 @@ INFO:     Application startup complete.
 </div>
 
 <details markdown="1">
-<summary>About the command <code>uvicorn main:app --reload</code>...</summary>
+<summary>About the command <code>fastapi dev main.py</code>...</summary>
 
-The command `uvicorn main:app` refers to:
+The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>.
 
-* `main`: the file `main.py` (the Python "module").
-* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
-* `--reload`: make the server restart after code changes. Only do this for development.
+By default, `fastapi dev` will start with auto-reload enabled for local development.
+
+You can read more about it in the <a href="https://fastapi.tiangolo.com/fastapi-cli/" target="_blank">FastAPI CLI docs</a>.
 
 </details>
 
@@ -302,7 +303,7 @@ def update_item(item_id: int, item: Item):
     return {"item_name": item.name, "item_id": item_id}
 ```
 
-The server should reload automatically (because you added `--reload` to the `uvicorn` command above).
+The `fastapi dev` server should reload automatically.
 
 ### Interactive API docs upgrade
 
@@ -446,7 +447,7 @@ Independent TechEmpower benchmarks show **FastAPI** applications running under U
 
 To understand more about it, see the section <a href="https://fastapi.tiangolo.com/benchmarks/" class="internal-link" target="_blank">Benchmarks</a>.
 
-## Optional Dependencies
+## Dependencies
 
 Used by Pydantic:
 
@@ -459,16 +460,33 @@ Used by Starlette:
 * <a href="https://www.python-httpx.org" target="_blank"><code>httpx</code></a> - Required if you want to use the `TestClient`.
 * <a href="https://jinja.palletsprojects.com" target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
 * <a href="https://github.com/Kludex/python-multipart" target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
-* <a href="https://pythonhosted.org/itsdangerous/" target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
-* <a href="https://pyyaml.org/wiki/PyYAMLDocumentation" target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
 
 Used by FastAPI / Starlette:
 
 * <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
 * <a href="https://github.com/ijl/orjson" target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
 * <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - Required if you want to use `UJSONResponse`.
+* `fastapi-cli` - to provide the `fastapi` command.
+
+When you install `fastapi` it comes these standard dependencies.
+
+## `fastapi-slim`
+
+If you don't want the extra standard optional dependencies, install `fastapi-slim` instead.
+
+When you install with:
+
+```bash
+pip install fastapi
+```
+
+...it includes the same code and dependencies as:
+
+```bash
+pip install "fastapi-slim[standard]"
+```
 
-You can install all of these with `pip install "fastapi[all]"`.
+The standard extra dependencies are the ones mentioned above.
 
 ## License
 
index b25c11b17720c270608916aa6ce038e659550c79..c17b024f9ffed2e8f92e8134739904952b98f73f 100644 (file)
@@ -22,7 +22,7 @@ Even though all your code is written assuming there's just `/app`.
 {!../../../docs_src/behind_a_proxy/tutorial001.py!}
 ```
 
-And the proxy would be **"stripping"** the **path prefix** on the fly before transmitting the request to Uvicorn, keeping your application convinced that it is being served at `/app`, so that you don't have to update all your code to include the prefix `/api/v1`.
+And the proxy would be **"stripping"** the **path prefix** on the fly before transmitting the request to the app server (probably Uvicorn via FastAPI CLI), keeping your application convinced that it is being served at `/app`, so that you don't have to update all your code to include the prefix `/api/v1`.
 
 Up to here, everything would work as normally.
 
@@ -63,7 +63,7 @@ The docs UI would also need the OpenAPI schema to declare that this API `server`
 }
 ```
 
-In this example, the "Proxy" could be something like **Traefik**. And the server would be something like **Uvicorn**, running your FastAPI application.
+In this example, the "Proxy" could be something like **Traefik**. And the server would be something like FastAPI CLI with **Uvicorn**, running your FastAPI application.
 
 ### Providing the `root_path`
 
@@ -72,7 +72,7 @@ To achieve this, you can use the command line option `--root-path` like:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --root-path /api/v1
+$ fastapi run main.py --root-path /api/v1
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
@@ -101,7 +101,7 @@ Then, if you start Uvicorn with:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --root-path /api/v1
+$ fastapi run main.py --root-path /api/v1
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
@@ -216,12 +216,12 @@ INFO[0000] Configuration loaded from file: /home/user/awesomeapi/traefik.toml
 
 </div>
 
-And now start your app with Uvicorn, using the `--root-path` option:
+And now start your app, using the `--root-path` option:
 
 <div class="termy">
 
 ```console
-$ uvicorn main:app --root-path /api/v1
+$ fastapi run main.py --root-path /api/v1
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
index 2785ee14075f15083c3126e6626c34b7dc36e875..1ff51f0779f1563410c63dd04c82cb991578b2a2 100644 (file)
@@ -172,7 +172,7 @@ Now use the parameter `callbacks` in *your API's path operation decorator* to pa
 
 ### Check the docs
 
-Now you can start your app with Uvicorn and go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
+Now you can start your app and go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
 
 You will see your docs including a "Callbacks" section for your *path operation* that shows how the *external API* should look like:
 
index 63cbdc6103c2f501c130a740f971684f1ec08e6f..f7f43b3572fd0dddf43bb6b248f4d1719ac01551 100644 (file)
@@ -44,7 +44,7 @@ This is because it is expected that **your users** would define the actual **URL
 
 ### Check the docs
 
-Now you can start your app with Uvicorn and go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
+Now you can start your app and go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
 
 You will see your docs have the normal *path operations* and now also some **webhooks**:
 
index 8f72bf63a82b3a3c792785aeb6094109147f6678..f9b525a5884f556783e958e5b45a42ae52b7780e 100644 (file)
@@ -199,7 +199,7 @@ Next, you would run the server passing the configurations as environment variabl
 <div class="termy">
 
 ```console
-$ ADMIN_EMAIL="deadpool@example.com" APP_NAME="ChimichangApp" uvicorn main:app
+$ ADMIN_EMAIL="deadpool@example.com" APP_NAME="ChimichangApp" fastapi run main.py
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
index b8dfab1d1f69fb210b4a6e222330a10baceddd7e..3b6471dd59a859c3699c8c4746f398377a4c71dc 100644 (file)
@@ -72,7 +72,7 @@ If your file is named `main.py`, run your application with:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
+$ fastapi dev main.py
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
@@ -160,7 +160,7 @@ If your file is named `main.py`, run your application with:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
+$ fastapi dev main.py
 
 <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
 ```
index 852e2501990909d139ccfd5a9dee70a499b7caa7..f07609ed6f82b2dd70d555c266f296b2c848b7a0 100644 (file)
@@ -22,7 +22,7 @@ Now, every request under the path `/v1/` will be handled by the Flask applicatio
 
 And the rest will be handled by **FastAPI**.
 
-If you run it with Uvicorn and go to <a href="http://localhost:8000/v1/" class="external-link" target="_blank">http://localhost:8000/v1/</a> you will see the response from Flask:
+If you run it and go to <a href="http://localhost:8000/v1/" class="external-link" target="_blank">http://localhost:8000/v1/</a> you will see the response from Flask:
 
 ```txt
 Hello, World from Flask!
index 406c00897c8d80ac78499a79e76085d9d7e7aff6..af2fbe670093dab84bd8faab4283f26896975234 100644 (file)
@@ -26,6 +26,7 @@
     position: relative;
     -webkit-box-sizing: border-box;
             box-sizing: border-box;
+    line-height: 1.2;
 }
 
 [data-termynal]:before {
index b771ae6634e257fcd739db434fed0c2cd8c5dc1b..9701c67d8408e629aa9c8b5eab04868f233cb86b 100644 (file)
@@ -94,7 +94,7 @@ In most cases, when you create a web API, you want it to be **always running**,
 
 ### In a Remote Server
 
-When you set up a remote server (a cloud server, a virtual machine, etc.) the simplest thing you can do is to run Uvicorn (or similar) manually, the same way you do when developing locally.
+When you set up a remote server (a cloud server, a virtual machine, etc.) the simplest thing you can do is to use `fastapi run`, Uvicorn (or similar) manually, the same way you do when developing locally.
 
 And it will work and will be useful **during development**.
 
index 467ba72deba8cc7687fec0487e9b95f344b3353c..5181f77e0d7e8e76071c5a527bcdb23ad3fed430 100644 (file)
@@ -21,10 +21,10 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 COPY ./app /code/app
 
-CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "app/main.py", "--port", "80"]
 
 # If running behind a proxy like Nginx or Traefik add --proxy-headers
-# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--proxy-headers"]
+# CMD ["fastapi", "run", "app/main.py", "--port", "80", "--proxy-headers"]
 ```
 
 </details>
@@ -113,9 +113,8 @@ You would of course use the same ideas you read in [About FastAPI versions](vers
 For example, your `requirements.txt` could look like:
 
 ```
-fastapi>=0.68.0,<0.69.0
-pydantic>=1.8.0,<2.0.0
-uvicorn>=0.15.0,<0.16.0
+fastapi>=0.112.0,<0.113.0
+pydantic>=2.7.0,<3.0.0
 ```
 
 And you would normally install those package dependencies with `pip`, for example:
@@ -125,7 +124,7 @@ And you would normally install those package dependencies with `pip`, for exampl
 ```console
 $ pip install -r requirements.txt
 ---> 100%
-Successfully installed fastapi pydantic uvicorn
+Successfully installed fastapi pydantic
 ```
 
 </div>
@@ -133,8 +132,6 @@ Successfully installed fastapi pydantic uvicorn
 !!! info
     There are other formats and tools to define and install package dependencies.
 
-    I'll show you an example using Poetry later in a section below. 👇
-
 ### Create the **FastAPI** Code
 
 * Create an `app` directory and enter it.
@@ -180,7 +177,7 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 COPY ./app /code/app
 
 # (6)
-CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "app/main.py", "--port", "80"]
 ```
 
 1. Start from the official Python base image.
@@ -214,14 +211,12 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
 
     So, it's important to put this **near the end** of the `Dockerfile`, to optimize the container image build times.
 
-6. Set the **command** to run the `uvicorn` server.
+6. Set the **command** to use `fastapi run`, which uses Uvicorn underneath.
 
     `CMD` takes a list of strings, each of these strings is what you would type in the command line separated by spaces.
 
     This command will be run from the **current working directory**, the same `/code` directory you set above with `WORKDIR /code`.
 
-    Because the program will be started at `/code` and inside of it is the directory `./app` with your code, **Uvicorn** will be able to see and **import** `app` from `app.main`.
-
 !!! tip
     Review what each line does by clicking each number bubble in the code. 👆
 
@@ -238,10 +233,10 @@ You should now have a directory structure like:
 
 #### Behind a TLS Termination Proxy
 
-If you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik, add the option `--proxy-headers`, this will tell Uvicorn to trust the headers sent by that proxy telling it that the application is running behind HTTPS, etc.
+If you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik, add the option `--proxy-headers`, this will tell Uvicorn (through the FastAPI CLI) to trust the headers sent by that proxy telling it that the application is running behind HTTPS, etc.
 
 ```Dockerfile
-CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "app/main.py", "--proxy-headers", "--port", "80"]
 ```
 
 #### Docker Cache
@@ -362,14 +357,14 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 COPY ./main.py /code/
 
 # (2)
-CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "main.py", "--port", "80"]
 ```
 
 1. Copy the `main.py` file to the `/code` directory directly (without any `./app` directory).
 
-2. Run Uvicorn and tell it to import the `app` object from `main` (instead of importing from `app.main`).
+2. Use `fastapi run` to serve your application in the single file `main.py`.
 
-Then adjust the Uvicorn command to use the new module `main` instead of `app.main` to import the FastAPI object `app`.
+When you pass the file to `fastapi run` it will detect automatically that it is a single file and not part of a package and will know how to import it and serve your FastAPI app. 😎
 
 ## Deployment Concepts
 
@@ -626,7 +621,7 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 COPY ./app /code/app
 
 # (11)
-CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "app/main.py", "--port", "80"]
 ```
 
 1. This is the first stage, it is named `requirements-stage`.
@@ -655,7 +650,7 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
 
 10. Copy the `app` directory to the `/code` directory.
 
-11. Run the `uvicorn` command, telling it to use the `app` object imported from `app.main`.
+11. Use the `fastapi run` command to run your app.
 
 !!! tip
     Click the bubble numbers to see what each line does.
@@ -677,7 +672,7 @@ Then in the next (and final) stage you would build the image more or less in the
 Again, if you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik, add the option `--proxy-headers` to the command:
 
 ```Dockerfile
-CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
+CMD ["fastapi", "run", "app/main.py", "--proxy-headers", "--port", "80"]
 ```
 
 ## Recap
index b10a3686d756554655ea4c8a753bef2e452bc657..3baaa825319c7a71ad9de03f5180456b1d64ab08 100644 (file)
@@ -1,8 +1,68 @@
-# Run a Server Manually - Uvicorn
+# Run a Server Manually
 
-The main thing you need to run a **FastAPI** application in a remote server machine is an ASGI server program like **Uvicorn**.
+## Use the `fastapi run` Command
 
-There are 3 main alternatives:
+In short, use `fastapi run` to serve your FastAPI application:
+
+<div class="termy">
+
+```console
+$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:single">main.py</u>
+<font color="#3465A4">INFO    </font> Using path <font color="#3465A4">main.py</font>
+<font color="#3465A4">INFO    </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
+<font color="#3465A4">INFO    </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
+<font color="#3465A4">INFO    </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
+
+ ╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
+ │                      │
+ │  🐍 main.py          │
+ │                      │
+ ╰──────────────────────╯
+
+<font color="#3465A4">INFO    </font> Importing module <font color="#4E9A06">main</font>
+<font color="#3465A4">INFO    </font> Found importable FastAPI app
+
+ ╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
+ │                          │
+ │  <span style="background-color:#272822"><font color="#FF4689">from</font></span><span style="background-color:#272822"><font color="#F8F8F2"> main </font></span><span style="background-color:#272822"><font color="#FF4689">import</font></span><span style="background-color:#272822"><font color="#F8F8F2"> app</font></span><span style="background-color:#272822">  </span>  │
+ │                          │
+ ╰──────────────────────────╯
+
+<font color="#3465A4">INFO    </font> Using import string <font color="#8AE234"><b>main:app</b></font>
+
+ <font color="#4E9A06">╭─────────── FastAPI CLI - Production mode ───────────╮</font>
+ <font color="#4E9A06">│                                                     │</font>
+ <font color="#4E9A06">│  Serving at: http://0.0.0.0:8000                    │</font>
+ <font color="#4E9A06">│                                                     │</font>
+ <font color="#4E9A06">│  API docs: http://0.0.0.0:8000/docs                 │</font>
+ <font color="#4E9A06">│                                                     │</font>
+ <font color="#4E9A06">│  Running in production mode, for development use:   │</font>
+ <font color="#4E9A06">│                                                     │</font>
+ <font color="#4E9A06">│  </font><font color="#8AE234"><b>fastapi dev</b></font><font color="#4E9A06">                                        │</font>
+ <font color="#4E9A06">│                                                     │</font>
+ <font color="#4E9A06">╰─────────────────────────────────────────────────────╯</font>
+
+<font color="#4E9A06">INFO</font>:     Started server process [<font color="#06989A">2306215</font>]
+<font color="#4E9A06">INFO</font>:     Waiting for application startup.
+<font color="#4E9A06">INFO</font>:     Application startup complete.
+<font color="#4E9A06">INFO</font>:     Uvicorn running on <b>http://0.0.0.0:8000</b> (Press CTRL+C to quit)
+```
+
+</div>
+
+That would work for most of the cases. 😎
+
+You could use that command for example to start your **FastAPI** app in a container, in a server, etc.
+
+## ASGI Servers
+
+Let's go a little deeper into the details.
+
+FastAPI uses a standard for building Python web frameworks and servers called <abbr title="Asynchronous Server Gateway Interface">ASGI</abbr>. FastAPI is an ASGI web framework.
+
+The main thing you need to run a **FastAPI** application (or any other ASGI application) in a remote server machine is an ASGI server program like **Uvicorn**, this is the one that comes by default in the `fastapi` command.
+
+There are several alternatives, including:
 
 * <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>: a high performance ASGI server.
 * <a href="https://pgjones.gitlab.io/hypercorn/" class="external-link" target="_blank">Hypercorn</a>: an ASGI server compatible with HTTP/2 and Trio among other features.
@@ -20,7 +80,9 @@ When referring to the remote machine, it's common to call it **server**, but als
 
 ## Install the Server Program
 
-You can install an ASGI compatible server with:
+When you install FastAPI, it comes with a production server, Uvicorn, and you can start it with the `fastapi run` command.
+
+But you can also install an ASGI server manually:
 
 === "Uvicorn"
 
@@ -41,6 +103,8 @@ You can install an ASGI compatible server with:
 
         That including `uvloop`, the high-performance drop-in replacement for `asyncio`, that provides the big concurrency performance boost.
 
+        When you install FastAPI with something like `pip install fastapi` you already get `uvicorn[standard]` as well.
+
 === "Hypercorn"
 
     * <a href="https://gitlab.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>, an ASGI server also compatible with HTTP/2.
@@ -59,7 +123,7 @@ You can install an ASGI compatible server with:
 
 ## Run the Server Program
 
-You can then run your application the same way you have done in the tutorials, but without the `--reload` option, e.g.:
+If you installed an ASGI server manually, you would normally need to pass an import string in a special format for it to import your FastAPI application:
 
 === "Uvicorn"
 
@@ -85,8 +149,20 @@ You can then run your application the same way you have done in the tutorials, b
 
     </div>
 
+!!! note
+    The command `uvicorn main:app` refers to:
+
+    * `main`: the file `main.py` (the Python "module").
+    * `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
+
+    It is equivalent to:
+
+    ```Python
+    from main import app
+    ```
+
 !!! warning
-    Remember to remove the `--reload` option if you were using it.
+    Uvicorn and others support a `--reload` option that is useful during development.
 
     The `--reload` option consumes much more resources, is more unstable, etc.
 
diff --git a/docs/en/docs/fastapi-cli.md b/docs/en/docs/fastapi-cli.md
new file mode 100644 (file)
index 0000000..0e6295b
--- /dev/null
@@ -0,0 +1,84 @@
+# FastAPI CLI
+
+**FastAPI CLI** is a command line program `fastapi` that you can use to serve your FastAPI app, manage your FastAPI project, and more.
+
+When you install FastAPI (e.g. with `pip install fastapi`), it includes a package called `fastapi-cli`, this package provides the `fastapi` command in the terminal.
+
+To run your FastAPI app for development, you can use the `fastapi dev` command:
+
+<div class="termy">
+
+```console
+$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:single">main.py</u>
+<font color="#3465A4">INFO    </font> Using path <font color="#3465A4">main.py</font>
+<font color="#3465A4">INFO    </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
+<font color="#3465A4">INFO    </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
+<font color="#3465A4">INFO    </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
+
+ ╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
+ │                      │
+ │  🐍 main.py          │
+ │                      │
+ ╰──────────────────────╯
+
+<font color="#3465A4">INFO    </font> Importing module <font color="#4E9A06">main</font>
+<font color="#3465A4">INFO    </font> Found importable FastAPI app
+
+ ╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
+ │                          │
+ │  <span style="background-color:#272822"><font color="#FF4689">from</font></span><span style="background-color:#272822"><font color="#F8F8F2"> main </font></span><span style="background-color:#272822"><font color="#FF4689">import</font></span><span style="background-color:#272822"><font color="#F8F8F2"> app</font></span><span style="background-color:#272822">  </span>  │
+ │                          │
+ ╰──────────────────────────╯
+
+<font color="#3465A4">INFO    </font> Using import string <font color="#8AE234"><b>main:app</b></font>
+
+ <span style="background-color:#C4A000"><font color="#2E3436">╭────────── FastAPI CLI - Development mode ───────────╮</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Serving at: http://127.0.0.1:8000                  │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  API docs: http://127.0.0.1:8000/docs               │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Running in development mode, for production use:   │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  </font></span><span style="background-color:#C4A000"><font color="#555753"><b>fastapi run</b></font></span><span style="background-color:#C4A000"><font color="#2E3436">                                        │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">╰─────────────────────────────────────────────────────╯</font></span>
+
+<font color="#4E9A06">INFO</font>:     Will watch for changes in these directories: [&apos;/home/user/code/awesomeapp&apos;]
+<font color="#4E9A06">INFO</font>:     Uvicorn running on <b>http://127.0.0.1:8000</b> (Press CTRL+C to quit)
+<font color="#4E9A06">INFO</font>:     Started reloader process [<font color="#34E2E2"><b>2265862</b></font>] using <font color="#34E2E2"><b>WatchFiles</b></font>
+<font color="#4E9A06">INFO</font>:     Started server process [<font color="#06989A">2265873</font>]
+<font color="#4E9A06">INFO</font>:     Waiting for application startup.
+<font color="#4E9A06">INFO</font>:     Application startup complete.
+```
+
+</div>
+
+That command line program called `fastapi` is **FastAPI CLI**.
+
+FastAPI CLI takes the path to your Python program and automatically detects the variable with the FastAPI (commonly named `app`) and how to import it, and then serves it.
+
+For production you would use `fastapi run` instead. 🚀
+
+Internally, **FastAPI CLI** uses <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>, a high-performance, production-ready, ASGI server. 😎
+
+## `fastapi dev`
+
+When you run `fastapi dev`, it will run on development mode.
+
+By default, it will have **auto-reload** enabled, so it will automatically reload the server when you make changes to your code. This is resource intensive and could be less stable than without it, you should only use it for development.
+
+By default it will listen on the IP address `127.0.0.1`, which is the IP for your machine to communicate with itself alone (`localhost`).
+
+## `fastapi run`
+
+When you run `fastapi run`, it will run on production mode by default.
+
+It will have **auto-reload disabled** by default.
+
+It will listen on the IP address `0.0.0.0`, which means all the available IP addresses, this way it will be publicly accessible to anyone that can communicate with the machine. This is how you would normally run it in production, for example, in a container.
+
+In most cases you would (and should) have a "termination proxy" handling HTTPS for you on top, this will depend on how you deploy your application, your provider might do this for you, or you might need to set it up yourself.
+
+!!! tip
+    You can learn more about it in the [deployment documentation](../deployment/index.md){.internal-link target=_blank}.
index 6f0e74b3d188243719c4c2ae92fb31b2a066e491..8afa13a985ba8abb39a8eac08f83ec83dc8d03c0 100644 (file)
@@ -30,7 +30,7 @@ Interactive API documentation and exploration web user interfaces. As the framew
 
 ### Just Modern Python
 
-It's all based on standard **Python 3.6 type** declarations (thanks to Pydantic). No new syntax to learn. Just standard modern Python.
+It's all based on standard **Python type** declarations (thanks to Pydantic). No new syntax to learn. Just standard modern Python.
 
 If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI), check the short tutorial: [Python Types](python-types.md){.internal-link target=_blank}.
 
@@ -77,7 +77,7 @@ my_second_user: User = User(**second_user_data)
 
 All the framework was designed to be easy and intuitive to use, all the decisions were tested on multiple editors even before starting development, to ensure the best development experience.
 
-In the last Python developer survey it was clear <a href="https://www.jetbrains.com/research/python-developers-survey-2017/#tools-and-features" class="external-link" target="_blank">that the most used feature is "autocompletion"</a>.
+In the Python developer surveys, it's clear <a href="https://www.jetbrains.com/research/python-developers-survey-2017/#tools-and-features" class="external-link" target="_blank">that one of the most used features is "autocompletion"</a>.
 
 The whole **FastAPI** framework is based to satisfy that. Autocompletion works everywhere.
 
index 508e859a1cf4ad8fbc6f7e089b784c6e24d689b5..434c708934436686867a3d07ea61ece2d23d2da5 100644 (file)
@@ -141,18 +141,6 @@ $ pip install fastapi
 
 </div>
 
-You will also need an ASGI server, for production such as <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a> or <a href="https://github.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>.
-
-<div class="termy">
-
-```console
-$ pip install "uvicorn[standard]"
-
----> 100%
-```
-
-</div>
-
 ## Example
 
 ### Create it
@@ -213,11 +201,24 @@ Run the server with:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
-
+$ fastapi dev main.py
+
+ ╭────────── FastAPI CLI - Development mode ───────────╮
+ │                                                     │
+ │  Serving at: http://127.0.0.1:8000                  │
+ │                                                     │
+ │  API docs: http://127.0.0.1:8000/docs               │
+ │                                                     │
+ │  Running in development mode, for production use:   │
+ │                                                     │
+ │  fastapi run                                        │
+ │                                                     │
+ ╰─────────────────────────────────────────────────────╯
+
+INFO:     Will watch for changes in these directories: ['/home/user/code/awesomeapp']
 INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-INFO:     Started reloader process [28720]
-INFO:     Started server process [28722]
+INFO:     Started reloader process [2248755] using WatchFiles
+INFO:     Started server process [2248757]
 INFO:     Waiting for application startup.
 INFO:     Application startup complete.
 ```
@@ -225,13 +226,13 @@ INFO:     Application startup complete.
 </div>
 
 <details markdown="1">
-<summary>About the command <code>uvicorn main:app --reload</code>...</summary>
+<summary>About the command <code>fastapi dev main.py</code>...</summary>
 
-The command `uvicorn main:app` refers to:
+The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>.
 
-* `main`: the file `main.py` (the Python "module").
-* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
-* `--reload`: make the server restart after code changes. Only do this for development.
+By default, `fastapi dev` will start with auto-reload enabled for local development.
+
+You can read more about it in the <a href="https://fastapi.tiangolo.com/fastapi-cli/" target="_blank">FastAPI CLI docs</a>.
 
 </details>
 
@@ -304,7 +305,7 @@ def update_item(item_id: int, item: Item):
     return {"item_name": item.name, "item_id": item_id}
 ```
 
-The server should reload automatically (because you added `--reload` to the `uvicorn` command above).
+The `fastapi dev` server should reload automatically.
 
 ### Interactive API docs upgrade
 
@@ -448,7 +449,7 @@ Independent TechEmpower benchmarks show **FastAPI** applications running under U
 
 To understand more about it, see the section <a href="https://fastapi.tiangolo.com/benchmarks/" class="internal-link" target="_blank">Benchmarks</a>.
 
-## Optional Dependencies
+## Dependencies
 
 Used by Pydantic:
 
@@ -461,16 +462,33 @@ Used by Starlette:
 * <a href="https://www.python-httpx.org" target="_blank"><code>httpx</code></a> - Required if you want to use the `TestClient`.
 * <a href="https://jinja.palletsprojects.com" target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
 * <a href="https://github.com/Kludex/python-multipart" target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
-* <a href="https://pythonhosted.org/itsdangerous/" target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
-* <a href="https://pyyaml.org/wiki/PyYAMLDocumentation" target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
 
 Used by FastAPI / Starlette:
 
 * <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
 * <a href="https://github.com/ijl/orjson" target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
 * <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - Required if you want to use `UJSONResponse`.
+* `fastapi-cli` - to provide the `fastapi` command.
+
+When you install `fastapi` it comes these standard dependencies.
+
+## `fastapi-slim`
+
+If you don't want the extra standard optional dependencies, install `fastapi-slim` instead.
+
+When you install with:
+
+```bash
+pip install fastapi
+```
+
+...it includes the same code and dependencies as:
+
+```bash
+pip install "fastapi-slim[standard]"
+```
 
-You can install all of these with `pip install "fastapi[all]"`.
+The standard extra dependencies are the ones mentioned above.
 
 ## License
 
index cfa159329405c35f681255b925ee1a6bd08fba38..35b2feb41b108adac9d0f849faa67b06a849a865 100644 (file)
@@ -13,24 +13,51 @@ Run the live server:
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
-
-<span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-<span style="color: green;">INFO</span>:     Started reloader process [28720]
-<span style="color: green;">INFO</span>:     Started server process [28722]
-<span style="color: green;">INFO</span>:     Waiting for application startup.
-<span style="color: green;">INFO</span>:     Application startup complete.
+$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:single">main.py</u>
+<font color="#3465A4">INFO    </font> Using path <font color="#3465A4">main.py</font>
+<font color="#3465A4">INFO    </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
+<font color="#3465A4">INFO    </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
+<font color="#3465A4">INFO    </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
+
+ ╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
+ │                      │
+ │  🐍 main.py          │
+ │                      │
+ ╰──────────────────────╯
+
+<font color="#3465A4">INFO    </font> Importing module <font color="#4E9A06">main</font>
+<font color="#3465A4">INFO    </font> Found importable FastAPI app
+
+ ╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
+ │                          │
+ │  <span style="background-color:#272822"><font color="#FF4689">from</font></span><span style="background-color:#272822"><font color="#F8F8F2"> main </font></span><span style="background-color:#272822"><font color="#FF4689">import</font></span><span style="background-color:#272822"><font color="#F8F8F2"> app</font></span><span style="background-color:#272822">  </span>  │
+ │                          │
+ ╰──────────────────────────╯
+
+<font color="#3465A4">INFO    </font> Using import string <font color="#8AE234"><b>main:app</b></font>
+
+ <span style="background-color:#C4A000"><font color="#2E3436">╭────────── FastAPI CLI - Development mode ───────────╮</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Serving at: http://127.0.0.1:8000                  │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  API docs: http://127.0.0.1:8000/docs               │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Running in development mode, for production use:   │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  </font></span><span style="background-color:#C4A000"><font color="#555753"><b>fastapi run</b></font></span><span style="background-color:#C4A000"><font color="#2E3436">                                        │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">╰─────────────────────────────────────────────────────╯</font></span>
+
+<font color="#4E9A06">INFO</font>:     Will watch for changes in these directories: [&apos;/home/user/code/awesomeapp&apos;]
+<font color="#4E9A06">INFO</font>:     Uvicorn running on <b>http://127.0.0.1:8000</b> (Press CTRL+C to quit)
+<font color="#4E9A06">INFO</font>:     Started reloader process [<font color="#34E2E2"><b>2265862</b></font>] using <font color="#34E2E2"><b>WatchFiles</b></font>
+<font color="#4E9A06">INFO</font>:     Started server process [<font color="#06989A">2265873</font>]
+<font color="#4E9A06">INFO</font>:     Waiting for application startup.
+<font color="#4E9A06">INFO</font>:     Application startup complete.
 ```
 
 </div>
 
-!!! note
-    The command `uvicorn main:app` refers to:
-
-    * `main`: the file `main.py` (the Python "module").
-    * `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
-    * `--reload`: make the server restart after code changes. Only use for development.
-
 In the output, there's a line with something like:
 
 ```hl_lines="4"
@@ -151,36 +178,6 @@ Here the `app` variable will be an "instance" of the class `FastAPI`.
 
 This will be the main point of interaction to create all your API.
 
-This `app` is the same one referred by `uvicorn` in the command:
-
-<div class="termy">
-
-```console
-$ uvicorn main:app --reload
-
-<span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-```
-
-</div>
-
-If you create your app like:
-
-```Python hl_lines="3"
-{!../../../docs_src/first_steps/tutorial002.py!}
-```
-
-And put it in a file `main.py`, then you would call `uvicorn` like:
-
-<div class="termy">
-
-```console
-$ uvicorn main:my_awesome_api --reload
-
-<span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-```
-
-</div>
-
 ### Step 3: create a *path operation*
 
 #### Path
index 75665324d91cb16d8e7fc6ad6cde3bf2a640c564..74fe06acd495e0cdce987586c51a3256dcca91b9 100644 (file)
@@ -12,18 +12,53 @@ So you can come back and see exactly what you need.
 
 All the code blocks can be copied and used directly (they are actually tested Python files).
 
-To run any of the examples, copy the code to a file `main.py`, and start `uvicorn` with:
+To run any of the examples, copy the code to a file `main.py`, and start `fastapi dev` with:
 
 <div class="termy">
 
 ```console
-$ uvicorn main:app --reload
-
-<span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
-<span style="color: green;">INFO</span>:     Started reloader process [28720]
-<span style="color: green;">INFO</span>:     Started server process [28722]
-<span style="color: green;">INFO</span>:     Waiting for application startup.
-<span style="color: green;">INFO</span>:     Application startup complete.
+$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:single">main.py</u>
+<font color="#3465A4">INFO    </font> Using path <font color="#3465A4">main.py</font>
+<font color="#3465A4">INFO    </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
+<font color="#3465A4">INFO    </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
+<font color="#3465A4">INFO    </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
+
+ ╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
+ │                      │
+ │  🐍 main.py          │
+ │                      │
+ ╰──────────────────────╯
+
+<font color="#3465A4">INFO    </font> Importing module <font color="#4E9A06">main</font>
+<font color="#3465A4">INFO    </font> Found importable FastAPI app
+
+ ╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
+ │                          │
+ │  <span style="background-color:#272822"><font color="#FF4689">from</font></span><span style="background-color:#272822"><font color="#F8F8F2"> main </font></span><span style="background-color:#272822"><font color="#FF4689">import</font></span><span style="background-color:#272822"><font color="#F8F8F2"> app</font></span><span style="background-color:#272822">  </span>  │
+ │                          │
+ ╰──────────────────────────╯
+
+<font color="#3465A4">INFO    </font> Using import string <font color="#8AE234"><b>main:app</b></font>
+
+ <span style="background-color:#C4A000"><font color="#2E3436">╭────────── FastAPI CLI - Development mode ───────────╮</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Serving at: http://127.0.0.1:8000                  │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  API docs: http://127.0.0.1:8000/docs               │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  Running in development mode, for production use:   │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│  </font></span><span style="background-color:#C4A000"><font color="#555753"><b>fastapi run</b></font></span><span style="background-color:#C4A000"><font color="#2E3436">                                        │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">│                                                     │</font></span>
+ <span style="background-color:#C4A000"><font color="#2E3436">╰─────────────────────────────────────────────────────╯</font></span>
+
+<font color="#4E9A06">INFO</font>:     Will watch for changes in these directories: [&apos;/home/user/code/awesomeapp&apos;]
+<font color="#4E9A06">INFO</font>:     Uvicorn running on <b>http://127.0.0.1:8000</b> (Press CTRL+C to quit)
+<font color="#4E9A06">INFO</font>:     Started reloader process [<font color="#34E2E2"><b>2265862</b></font>] using <font color="#34E2E2"><b>WatchFiles</b></font>
+<font color="#4E9A06">INFO</font>:     Started server process [<font color="#06989A">2265873</font>]
+<font color="#4E9A06">INFO</font>:     Waiting for application startup.
+<font color="#4E9A06">INFO</font>:     Application startup complete.
+</pre>
 ```
 
 </div>
@@ -36,38 +71,22 @@ Using it in your editor is what really shows you the benefits of FastAPI, seeing
 
 ## Install FastAPI
 
-The first step is to install FastAPI.
-
-For the tutorial, you might want to install it with all the optional dependencies and features:
+The first step is to install FastAPI:
 
 <div class="termy">
 
 ```console
-$ pip install "fastapi[all]"
+$ pip install fastapi
 
 ---> 100%
 ```
 
 </div>
 
-...that also includes `uvicorn`, that you can use as the server that runs your code.
-
 !!! note
-    You can also install it part by part.
-
-    This is what you would probably do once you want to deploy your application to production:
-
-    ```
-    pip install fastapi
-    ```
-
-    Also install `uvicorn` to work as the server:
-
-    ```
-    pip install "uvicorn[standard]"
-    ```
+    When you install with `pip install fastapi` it comes with some default optional standard dependencies.
 
-    And the same for each of the optional dependencies that you want to use.
+    If you don't want to have those optional dependencies, you can instead install `pip install fastapi-slim`.
 
 ## Advanced User Guide
 
index 933e7e4a2a4406335dffcefa4286e0731162e103..05dffb70640070bf546888b3a94000b5521591c2 100644 (file)
@@ -167,6 +167,7 @@ nav:
     - advanced/openapi-webhooks.md
     - advanced/wsgi.md
     - advanced/generate-clients.md
+  - fastapi-cli.md
   - Deployment:
     - deployment/index.md
     - deployment/versions.md
index 05c68841ffce55229609eae1d0b910b194562b9b..a79845646342bec9f71b37454af67c1cae46f327 100644 (file)
@@ -54,6 +54,7 @@ Repository = "https://github.com/tiangolo/fastapi"
 [project.optional-dependencies]
 
 standard = [
+    "fastapi-cli >=0.0.2",
     # For the test client
     "httpx >=0.23.0",
     # For templates
@@ -76,6 +77,7 @@ standard = [
 ]
 
 all = [
+    "fastapi-cli >=0.0.2",
     # # For the test client
     "httpx >=0.23.0",
     # For templates