]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
๐Ÿ“ Update docs for `fastapi-cli` (#13031)
authorSebastiรกn Ramรญrez <tiangolo@gmail.com>
Wed, 4 Dec 2024 14:38:39 +0000 (15:38 +0100)
committerGitHub <noreply@github.com>
Wed, 4 Dec 2024 14:38:39 +0000 (15:38 +0100)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
docs/en/docs/fastapi-cli.md
tests/test_fastapi_cli.py

index e27bebcb4cd72d06f21944f36776bc1f4053112d..654d2fe912b63bf2fca38f7da8185e92d20aa167 100644 (file)
@@ -9,47 +9,39 @@ 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.
+$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:solid">main.py</u>
+
+  <span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span>  Starting development server ๐Ÿš€
+
+             Searching for package file structure from directories with
+             <font color="#3465A4">__init__.py</font> files
+             Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
+
+   <span style="background-color:#007166"><font color="#D3D7CF"> module </font></span>  ๐Ÿ main.py
+
+     <span style="background-color:#007166"><font color="#D3D7CF"> code </font></span>  Importing the FastAPI app object from the module with the
+             following code:
+
+             <u style="text-decoration-style:solid">from </u><u style="text-decoration-style:solid"><b>main</b></u><u style="text-decoration-style:solid"> import </u><u style="text-decoration-style:solid"><b>app</b></u>
+
+      <span style="background-color:#007166"><font color="#D3D7CF"> app </font></span>  Using import string: <font color="#3465A4">main:app</font>
+
+   <span style="background-color:#007166"><font color="#D3D7CF"> server </font></span>  Server started at <font color="#729FCF"><u style="text-decoration-style:solid">http://127.0.0.1:8000</u></font>
+   <span style="background-color:#007166"><font color="#D3D7CF"> server </font></span>  Documentation at <font color="#729FCF"><u style="text-decoration-style:solid">http://127.0.0.1:8000/docs</u></font>
+
+      <span style="background-color:#007166"><font color="#D3D7CF"> tip </font></span>  Running in development mode, for production use:
+             <b>fastapi run</b>
+
+             Logs:
+
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Will watch for changes in these directories:
+             <b>[</b><font color="#4E9A06">&apos;/home/user/code/awesomeapp&apos;</font><b>]</b>
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Uvicorn running on <font color="#729FCF"><u style="text-decoration-style:solid">http://127.0.0.1:8000</u></font> <b>(</b>Press CTRL+C to
+             quit<b>)</b>
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Started reloader process <b>[</b><font color="#34E2E2"><b>383138</b></font><b>]</b> using WatchFiles
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Started server process <b>[</b><font color="#34E2E2"><b>383153</b></font><b>]</b>
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Waiting for application startup.
+     <span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span>  Application startup complete.
 ```
 
 </div>
index 20c928157016de3e7bbbe0a2b4975f6542d8e3ee..a5c10778ad7e85f1eed28a46329f1df99e66103c 100644 (file)
@@ -22,7 +22,7 @@ def test_fastapi_cli():
         encoding="utf-8",
     )
     assert result.returncode == 1, result.stdout
-    assert "Using path non_existent_file.py" in result.stdout
+    assert "Path does not exist non_existent_file.py" in result.stdout
 
 
 def test_fastapi_cli_not_installed():