Skip to content

Commit e2551fe

Browse files
Zhongheng-Chengs-rigaud
authored andcommitted
📝 Update fastapi-cli UI examples in docs (fastapi#13107)
1 parent d22600a commit e2551fe

File tree

4 files changed

+130
-172
lines changed

4 files changed

+130
-172
lines changed

docs/en/docs/deployment/manually.md

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,33 @@ In short, use `fastapi run` to serve your FastAPI application:
77
<div class="termy">
88

99
```console
10-
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:single">main.py</u>
11-
<font color="#3465A4">INFO </font> Using path <font color="#3465A4">main.py</font>
12-
<font color="#3465A4">INFO </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
13-
<font color="#3465A4">INFO </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
14-
<font color="#3465A4">INFO </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
15-
16-
╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
17-
│ │
18-
│ 🐍 main.py │
19-
│ │
20-
╰──────────────────────╯
21-
22-
<font color="#3465A4">INFO </font> Importing module <font color="#4E9A06">main</font>
23-
<font color="#3465A4">INFO </font> Found importable FastAPI app
24-
25-
╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
26-
│ │
27-
│ <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> │
28-
│ │
29-
╰──────────────────────────╯
30-
31-
<font color="#3465A4">INFO </font> Using import string <font color="#8AE234"><b>main:app</b></font>
32-
33-
<font color="#4E9A06">╭─────────── FastAPI CLI - Production mode ───────────╮</font>
34-
<font color="#4E9A06">│ │</font>
35-
<font color="#4E9A06">│ Serving at: http://0.0.0.0:8000 │</font>
36-
<font color="#4E9A06">│ │</font>
37-
<font color="#4E9A06">│ API docs: http://0.0.0.0:8000/docs │</font>
38-
<font color="#4E9A06">│ │</font>
39-
<font color="#4E9A06">│ Running in production mode, for development use: │</font>
40-
<font color="#4E9A06">│ │</font>
41-
<font color="#4E9A06">│ </font><font color="#8AE234"><b>fastapi dev</b></font><font color="#4E9A06"> │</font>
42-
<font color="#4E9A06">│ │</font>
43-
<font color="#4E9A06">╰─────────────────────────────────────────────────────╯</font>
44-
45-
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">2306215</font>]
46-
<font color="#4E9A06">INFO</font>: Waiting for application startup.
47-
<font color="#4E9A06">INFO</font>: Application startup complete.
48-
<font color="#4E9A06">INFO</font>: Uvicorn running on <b>http://0.0.0.0:8000</b> (Press CTRL+C to quit)
10+
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
11+
12+
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting production server 🚀
13+
14+
Searching for package file structure from directories
15+
with <font color="#3465A4">__init__.py</font> files
16+
Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
17+
18+
<span style="background-color:#007166"><font color="#D3D7CF"> module </font></span> 🐍 main.py
19+
20+
<span style="background-color:#007166"><font color="#D3D7CF"> code </font></span> Importing the FastAPI app object from the module with
21+
the following code:
22+
23+
<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>
24+
25+
<span style="background-color:#007166"><font color="#D3D7CF"> app </font></span> Using import string: <font color="#3465A4">main:app</font>
26+
27+
<span style="background-color:#007166"><font color="#D3D7CF"> server </font></span> Server started at <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000</u></font>
28+
<span style="background-color:#007166"><font color="#D3D7CF"> server </font></span> Documentation at <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000/docs</u></font>
29+
30+
Logs:
31+
32+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>2306215</b></font><b>]</b>
33+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
34+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
35+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Uvicorn running on <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000</u></font> <b>(</b>Press CTRL+C
36+
to quit<b>)</b>
4937
```
5038

5139
</div>

docs/en/docs/deployment/server-workers.md

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,56 +36,43 @@ If you use the `fastapi` command:
3636
<div class="termy">
3737

3838
```console
39-
$ <pre> <font color="#4E9A06">fastapi</font> run --workers 4 <u style="text-decoration-style:single">main.py</u>
40-
<font color="#3465A4">INFO </font> Using path <font color="#3465A4">main.py</font>
41-
<font color="#3465A4">INFO </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
42-
<font color="#3465A4">INFO </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
43-
<font color="#3465A4">INFO </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
44-
45-
╭─ <font color="#8AE234"><b>Python module file</b></font> ─╮
46-
│ │
47-
│ 🐍 main.py │
48-
│ │
49-
╰──────────────────────╯
50-
51-
<font color="#3465A4">INFO </font> Importing module <font color="#4E9A06">main</font>
52-
<font color="#3465A4">INFO </font> Found importable FastAPI app
53-
54-
╭─ <font color="#8AE234"><b>Importable FastAPI app</b></font> ─╮
55-
│ │
56-
│ <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> │
57-
│ │
58-
╰──────────────────────────╯
59-
60-
<font color="#3465A4">INFO </font> Using import string <font color="#8AE234"><b>main:app</b></font>
61-
62-
<font color="#4E9A06">╭─────────── FastAPI CLI - Production mode ───────────╮</font>
63-
<font color="#4E9A06">│ │</font>
64-
<font color="#4E9A06">│ Serving at: http://0.0.0.0:8000 │</font>
65-
<font color="#4E9A06">│ │</font>
66-
<font color="#4E9A06">│ API docs: http://0.0.0.0:8000/docs │</font>
67-
<font color="#4E9A06">│ │</font>
68-
<font color="#4E9A06">│ Running in production mode, for development use: │</font>
69-
<font color="#4E9A06">│ │</font>
70-
<font color="#4E9A06">│ </font><font color="#8AE234"><b>fastapi dev</b></font><font color="#4E9A06"> │</font>
71-
<font color="#4E9A06">│ │</font>
72-
<font color="#4E9A06">╰─────────────────────────────────────────────────────╯</font>
73-
74-
<font color="#4E9A06">INFO</font>: Uvicorn running on <b>http://0.0.0.0:8000</b> (Press CTRL+C to quit)
75-
<font color="#4E9A06">INFO</font>: Started parent process [<font color="#34E2E2"><b>27365</b></font>]
76-
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">27368</font>]
77-
<font color="#4E9A06">INFO</font>: Waiting for application startup.
78-
<font color="#4E9A06">INFO</font>: Application startup complete.
79-
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">27369</font>]
80-
<font color="#4E9A06">INFO</font>: Waiting for application startup.
81-
<font color="#4E9A06">INFO</font>: Application startup complete.
82-
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">27370</font>]
83-
<font color="#4E9A06">INFO</font>: Waiting for application startup.
84-
<font color="#4E9A06">INFO</font>: Application startup complete.
85-
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">27367</font>]
86-
<font color="#4E9A06">INFO</font>: Waiting for application startup.
87-
<font color="#4E9A06">INFO</font>: Application startup complete.
88-
</pre>
39+
$ <font color="#4E9A06">fastapi</font> run --workers 4 <u style="text-decoration-style:solid">main.py</u>
40+
41+
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting production server 🚀
42+
43+
Searching for package file structure from directories with
44+
<font color="#3465A4">__init__.py</font> files
45+
Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
46+
47+
<span style="background-color:#007166"><font color="#D3D7CF"> module </font></span> 🐍 main.py
48+
49+
<span style="background-color:#007166"><font color="#D3D7CF"> code </font></span> Importing the FastAPI app object from the module with the
50+
following code:
51+
52+
<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>
53+
54+
<span style="background-color:#007166"><font color="#D3D7CF"> app </font></span> Using import string: <font color="#3465A4">main:app</font>
55+
56+
<span style="background-color:#007166"><font color="#D3D7CF"> server </font></span> Server started at <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000</u></font>
57+
<span style="background-color:#007166"><font color="#D3D7CF"> server </font></span> Documentation at <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000/docs</u></font>
58+
59+
Logs:
60+
61+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Uvicorn running on <font color="#729FCF"><u style="text-decoration-style:solid">http://0.0.0.0:8000</u></font> <b>(</b>Press CTRL+C to
62+
quit<b>)</b>
63+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started parent process <b>[</b><font color="#34E2E2"><b>27365</b></font><b>]</b>
64+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>27368</b></font><b>]</b>
65+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>27369</b></font><b>]</b>
66+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>27370</b></font><b>]</b>
67+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Started server process <b>[</b><font color="#34E2E2"><b>27367</b></font><b>]</b>
68+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
69+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
70+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
71+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Waiting for application startup.
72+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
73+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
74+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
75+
<span style="background-color:#007166"><font color="#D3D7CF"> INFO </font></span> Application startup complete.
8976
```
9077

9178
</div>

0 commit comments

Comments
 (0)