Najprostszy plik FastAPI mo偶e wygl膮da膰 tak:
-```Python
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py *}
Skopiuj to do pliku `main.py`.
### Krok 1: zaimportuj `FastAPI`
-```Python hl_lines="1"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[1] *}
`FastAPI` jest klas膮, kt贸ra zapewnia wszystkie funkcjonalno艣ci Twojego API.
### Krok 2: utw贸rz instancj臋 `FastAPI`
-```Python hl_lines="3"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{*../../docs_src/first_steps/tutorial001.py hl[3] *}
Zmienna `app` b臋dzie tutaj "instancj膮" klasy `FastAPI`.
Je艣li stworzysz swoj膮 aplikacj臋, np.:
-```Python hl_lines="3"
-{!../../docs_src/first_steps/tutorial002.py!}
-```
+{* ../../docs_src/first_steps/tutorial002.py hl[3] *}
I umie艣cisz to w pliku `main.py`, to b臋dziesz m贸g艂 tak wywo艂a膰 `uvicorn`:
#### Zdefiniuj *dekorator operacji na 艣cie偶ce*
-```Python hl_lines="6"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[6] *}
`@app.get("/")` m贸wi **FastAPI** 偶e funkcja poni偶ej odpowiada za obs艂ug臋 偶膮da艅, kt贸re trafiaj膮 do:
* **operacja**: to `get`.
* **funkcja**: to funkcja poni偶ej "dekoratora" (poni偶ej `@app.get("/")`).
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[7] *}
Jest to funkcja Python.
Mo偶esz r贸wnie偶 zdefiniowa膰 to jako normaln膮 funkcj臋 zamiast `async def`:
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial003.py!}
-```
+{* ../../docs_src/first_steps/tutorial003.py hl[7] *}
/// note
### Krok 5: zwr贸膰 zawarto艣膰
-```Python hl_lines="8"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[8] *}
Mo偶esz zwr贸ci膰 `dict`, `list`, pojedyncz膮 warto艣膰 jako `str`, `int`, itp.