Skip to content

Commit 0a8e246

Browse files
tiangolos-rigaud
authored andcommitted
📝 Update includes in docs/en/docs/tutorial/first-steps.md (fastapi#12552)
1 parent ecd1745 commit 0a8e246

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

docs/en/docs/tutorial/first-steps.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
The simplest FastAPI file could look like this:
44

5-
```Python
6-
{!../../docs_src/first_steps/tutorial001.py!}
7-
```
5+
{* ../../docs_src/first_steps/tutorial001.py *}
86

97
Copy that to a file `main.py`.
108

@@ -157,9 +155,7 @@ You could also use it to generate code automatically, for clients that communica
157155

158156
### Step 1: import `FastAPI`
159157

160-
```Python hl_lines="1"
161-
{!../../docs_src/first_steps/tutorial001.py!}
162-
```
158+
{* ../../docs_src/first_steps/tutorial001.py hl[1] *}
163159

164160
`FastAPI` is a Python class that provides all the functionality for your API.
165161

@@ -173,9 +169,7 @@ You can use all the <a href="https://www.starlette.io/" class="external-link" ta
173169

174170
### Step 2: create a `FastAPI` "instance"
175171

176-
```Python hl_lines="3"
177-
{!../../docs_src/first_steps/tutorial001.py!}
178-
```
172+
{* ../../docs_src/first_steps/tutorial001.py hl[3] *}
179173

180174
Here the `app` variable will be an "instance" of the class `FastAPI`.
181175

@@ -244,9 +238,7 @@ We are going to call them "**operations**" too.
244238

245239
#### Define a *path operation decorator*
246240

247-
```Python hl_lines="6"
248-
{!../../docs_src/first_steps/tutorial001.py!}
249-
```
241+
{* ../../docs_src/first_steps/tutorial001.py hl[6] *}
250242

251243
The `@app.get("/")` tells **FastAPI** that the function right below is in charge of handling requests that go to:
252244

@@ -300,9 +292,7 @@ This is our "**path operation function**":
300292
* **operation**: is `get`.
301293
* **function**: is the function below the "decorator" (below `@app.get("/")`).
302294

303-
```Python hl_lines="7"
304-
{!../../docs_src/first_steps/tutorial001.py!}
305-
```
295+
{* ../../docs_src/first_steps/tutorial001.py hl[7] *}
306296

307297
This is a Python function.
308298

@@ -314,9 +304,7 @@ In this case, it is an `async` function.
314304

315305
You could also define it as a normal function instead of `async def`:
316306

317-
```Python hl_lines="7"
318-
{!../../docs_src/first_steps/tutorial003.py!}
319-
```
307+
{* ../../docs_src/first_steps/tutorial003.py hl[7] *}
320308

321309
/// note
322310

@@ -326,9 +314,7 @@ If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md
326314

327315
### Step 5: return the content
328316

329-
```Python hl_lines="8"
330-
{!../../docs_src/first_steps/tutorial001.py!}
331-
```
317+
{* ../../docs_src/first_steps/tutorial001.py hl[8] *}
332318

333319
You can return a `dict`, `list`, singular values as `str`, `int`, etc.
334320

0 commit comments

Comments
 (0)