Skip to content

Commit 1b594ff

Browse files
committed
Update docs/tutorial/fastapi/simple-hero-api.md
1 parent 893f8bd commit 1b594ff

File tree

1 file changed

+10
-193
lines changed

1 file changed

+10
-193
lines changed

docs/tutorial/fastapi/simple-hero-api.md

Lines changed: 10 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -32,52 +32,11 @@ We will start with the **simplest version**, with just heroes (no teams yet).
3232

3333
This is almost the same code we have seen up to now in previous examples:
3434

35-
//// tab | Python 3.10+
36-
37-
```Python hl_lines="18-19"
38-
39-
# One line of FastAPI imports here later 👈
40-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:2]!}
41-
42-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:5-20]!}
43-
44-
# Code below omitted 👇
45-
```
46-
47-
////
48-
49-
//// tab | Python 3.7+
50-
51-
```Python hl_lines="20-21"
52-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:1]!}
53-
54-
# One line of FastAPI imports here later 👈
55-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:4]!}
56-
57-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:7-22]!}
58-
59-
# Code below omitted 👇
60-
```
61-
62-
////
35+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[2] hl[18:19] *}
6336

6437
/// details | 👀 Full file preview
6538

66-
//// tab | Python 3.10+
67-
68-
```Python
69-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py!}
70-
```
71-
72-
////
73-
74-
//// tab | Python 3.7+
75-
76-
```Python
77-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py!}
78-
```
79-
80-
////
39+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py *}
8140

8241
///
8342

@@ -107,51 +66,11 @@ We will import the `FastAPI` class from `fastapi`.
10766

10867
And then create an `app` object that is an instance of that `FastAPI` class:
10968

110-
//// tab | Python 3.10+
111-
112-
```Python hl_lines="1 6"
113-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:1-2]!}
114-
115-
# SQLModel code here omitted 👈
116-
117-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:23]!}
118-
119-
# Code below omitted 👇
120-
```
121-
122-
////
123-
124-
//// tab | Python 3.7+
125-
126-
```Python hl_lines="3 8"
127-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:1-4]!}
128-
129-
# SQLModel code here omitted 👈
130-
131-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:25]!}
132-
133-
# Code below omitted 👇
134-
```
135-
136-
////
69+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[1:2] hl[1,6] *}
13770

13871
/// details | 👀 Full file preview
13972

140-
//// tab | Python 3.10+
141-
142-
```Python
143-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py!}
144-
```
145-
146-
////
147-
148-
//// tab | Python 3.7+
149-
150-
```Python
151-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py!}
152-
```
153-
154-
////
73+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py *}
15574

15675
///
15776

@@ -161,47 +80,11 @@ We want to make sure that once the app starts running, the function `create_tabl
16180

16281
This should be called only once at startup, not before every request, so we put it in the function to handle the `"startup"` event:
16382

164-
//// tab | Python 3.10+
165-
166-
```Python hl_lines="6-8"
167-
# Code above omitted 👆
168-
169-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:23-28]!}
170-
171-
# Code below omitted 👇
172-
```
173-
174-
////
175-
176-
//// tab | Python 3.7+
177-
178-
```Python hl_lines="6-8"
179-
# Code above omitted 👆
180-
181-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:25-30]!}
182-
183-
# Code below omitted 👇
184-
```
185-
186-
////
83+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[23:28] hl[6:8] *}
18784

18885
/// details | 👀 Full file preview
18986

190-
//// tab | Python 3.10+
191-
192-
```Python
193-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py!}
194-
```
195-
196-
////
197-
198-
//// tab | Python 3.7+
199-
200-
```Python
201-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py!}
202-
```
203-
204-
////
87+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py *}
20588

20689
///
20790

@@ -217,47 +100,13 @@ Let's create the **path operation** code to create a new hero.
217100

218101
It will be called when a user sends a request with a `POST` **operation** to the `/heroes/` **path**:
219102

220-
//// tab | Python 3.10+
221-
222-
```Python hl_lines="11-12"
223-
# Code above omitted 👆
224-
225-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:23-37]!}
226-
227-
# Code below omitted 👇
228-
```
229-
230-
////
231-
232-
//// tab | Python 3.7+
233-
234-
```Python hl_lines="11-12"
235-
# Code above omitted 👆
236-
237-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:25-39]!}
238-
239-
# Code below omitted 👇
240-
```
241-
242-
////
103+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[23:37] hl[11:12] *}
243104

244105
/// details | 👀 Full file preview
245106

246107
//// tab | Python 3.10+
247108

248-
```Python
249-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py!}
250-
```
251-
252-
////
253-
254-
//// tab | Python 3.7+
255-
256-
```Python
257-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py!}
258-
```
259-
260-
////
109+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py *}
261110

262111
///
263112

@@ -293,43 +142,11 @@ We will improve this further later, but for now, it already shows the power of h
293142

294143
Now let's add another **path operation** to read all the heroes:
295144

296-
//// tab | Python 3.10+
297-
298-
```Python hl_lines="20-24"
299-
# Code above omitted 👆
300-
301-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py[ln:23-44]!}
302-
```
303-
304-
////
305-
306-
//// tab | Python 3.7+
307-
308-
```Python hl_lines="20-24"
309-
# Code above omitted 👆
310-
311-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py[ln:25-46]!}
312-
```
313-
314-
////
145+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[23:44] hl[20:24] *}
315146

316147
/// details | 👀 Full file preview
317148

318-
//// tab | Python 3.10+
319-
320-
```Python
321-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py!}
322-
```
323-
324-
////
325-
326-
//// tab | Python 3.7+
327-
328-
```Python
329-
{!./docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py!}
330-
```
331-
332-
////
149+
{* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py *}
333150

334151
///
335152

0 commit comments

Comments
 (0)