Browse Source
* This PR translates advanced/sub-applications.md in Korean. Test complete related: #2017 * Update sub-applications.md * Update sub-applications.md * Update sub-applications.md * remove .DS_Store * ๐จ [pre-commit.ci] Auto format from pre-commit.com hooks * Update docs/ko/docs/advanced/sub-applications.md * Update docs/ko/docs/advanced/sub-applications.md * Update docs/ko/docs/advanced/sub-applications.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sebastiรกn Ramรญrez <[email protected]> Co-authored-by: Motov Yurii <[email protected]>pull/13284/merge
committed by
GitHub
1 changed files with 67 additions and 0 deletions
@ -0,0 +1,67 @@ |
|||
# ํ์ ์์ฉํ๋ก๊ทธ๋จ - ๋ง์ดํธ |
|||
|
|||
๋ง์ฝ ๊ฐ๊ฐ์ ๋
๋ฆฝ์ ์ธ OpenAPI์ ๋ฌธ์ UI๋ฅผ ๊ฐ๋ ๋ ๊ฐ์ ๋
๋ฆฝ์ ์ธ FastAPI ์์ฉํ๋ก๊ทธ๋จ์ด ํ์ํ๋ค๋ฉด, ๋ฉ์ธ ์ดํ๋ฆฌ์ผ์ด์
์ ํ๋ (๋๋ ๊ทธ ์ด์์) ํ์-์์ฉํ๋ก๊ทธ๋จ(๋ค)์ โ๋ง์ดํธ"ํด์ ์ฌ์ฉํ ์ ์์ต๋๋ค. |
|||
|
|||
## **FastAPI** ์์ฉํ๋ก๊ทธ๋จ ๋ง์ดํธ |
|||
|
|||
โ๋ง์ดํธ"์ด๋ ์์ ํ โ๋
๋ฆฝ์ ์ธ" ์์ฉํ๋ก๊ทธ๋จ์ ํน์ ๊ฒฝ๋ก์ ์ถ๊ฐํ์ฌ ํด๋น ํ์ ์์ฉํ๋ก๊ทธ๋จ์์ ์ ์ธ๋ *๊ฒฝ๋ก ๋์*์ ํตํด ํด๋น ๊ฒฝ๋ก ์๋์ ์๋ ๋ชจ๋ ์์
๋ค์ ์ฒ๋ฆฌํ ์ ์๋๋ก ํ๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. |
|||
|
|||
### ์ต์๋จ ์์ฉํ๋ก๊ทธ๋จ |
|||
|
|||
๋จผ์ , ๋ฉ์ธ, ์ต์๋จ์ **FastAPI** ์์ฉํ๋ก๊ทธ๋จ๊ณผ ์ด๊ฒ์ *๊ฒฝ๋ก ๋์*์ ์์ฑํฉ๋๋ค: |
|||
|
|||
{* ../../docs_src/sub_applications/tutorial001.py hl[3, 6:8] *} |
|||
|
|||
### ํ์ ์์ฉํ๋ก๊ทธ๋จ |
|||
|
|||
๋ค์์ผ๋ก, ํ์ ์์ฉํ๋ก๊ทธ๋จ๊ณผ ์ด๊ฒ์ *๊ฒฝ๋ก ๋์*์ ์์ฑํฉ๋๋ค: |
|||
|
|||
์ด ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ ๋ค๋ฅธ ํ์ค FastAPI ์์ฉํ๋ก๊ทธ๋จ์
๋๋ค. ๋ค๋ง ์ด๊ฒ์ โ๋ง์ดํธโ๋ ๊ฒ์
๋๋ค: |
|||
|
|||
{* ../../docs_src/sub_applications/tutorial001.py hl[11, 14:16] *} |
|||
|
|||
### ํ์ ์์ฉํ๋ก๊ทธ๋จ ๋ง์ดํธ |
|||
|
|||
์ต์๋จ ์์ฉํ๋ก๊ทธ๋จ, `app`์ ํ์ ์์ฉํ๋ก๊ทธ๋จ, `subapi`๋ฅผ ๋ง์ดํธํฉ๋๋ค. |
|||
|
|||
์ด ์์์์, ํ์ ์์ฉํ๋ก๊ทธ๋จ์
์ `/subapi` ๊ฒฝ๋ก์ ๋ง์ดํธ ๋ ๊ฒ์
๋๋ค: |
|||
|
|||
{* ../../docs_src/sub_applications/tutorial001.py hl[11, 19] *} |
|||
|
|||
### ์๋์ผ๋ก ์์ฑ๋ API ๋ฌธ์ ํ์ธ |
|||
|
|||
์ด์ , `uvicorn`์ผ๋ก ๋ฉ์ธ ์์ฉํ๋ก๊ทธ๋จ์ ์คํํ์ญ์์ค. ๋น์ ์ ํ์ผ์ด `main.py`๋ผ๋ฉด, ์ด๋ ๊ฒ ์คํํฉ๋๋ค: |
|||
|
|||
<div class="termy"> |
|||
|
|||
```console |
|||
$ uvicorn main:app --reload |
|||
|
|||
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) |
|||
``` |
|||
|
|||
</div> |
|||
|
|||
๊ทธ๋ฆฌ๊ณ <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>์์ ๋ฌธ์๋ฅผ ์ฌ์ญ์์ค. |
|||
|
|||
๋ฉ์ธ ์์ฉํ๋ก๊ทธ๋จ์ *๊ฒฝ๋ก ๋์*๋ง์ ํฌํจํ๋, ๋ฉ์ธ ์์ฉํ๋ก๊ทธ๋จ์ ๋ํ ์๋ API ๋ฌธ์๋ฅผ ํ์ธํ ์ ์์ต๋๋ค: |
|||
|
|||
<img src="https://fastapi.tiangolo.com//img/tutorial/sub-applications/image01.png"> |
|||
|
|||
๋ค์์ผ๋ก, <a href="http://127.0.0.1:8000/subapi/docs" class="external-link" target="_blank">http://127.0.0.1:8000/subapi/docs</a>์์ ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ฌธ์๋ฅผ ์ฌ์ญ์์ค. |
|||
|
|||
ํ์ ๊ฒฝ๋ก ์ ๋์ฌ `/subapi` ์๋์ ์ ์ธ๋ *๊ฒฝ๋ก ๋์* ์ ํฌํจํ๋, ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ํ ์๋ API ๋ฌธ์๋ฅผ ํ์ธํ ์ ์์ต๋๋ค: |
|||
|
|||
<img src="https://fastapi.tiangolo.com//img/tutorial/sub-applications/image02.png"> |
|||
|
|||
๋ ์ฌ์ฉ์ ์ธํฐํ์ด์ค ์ค ์ด๋ ํ๋๋ฅผ ์ฌ์ฉํด์ผํ๋ ๊ฒฝ์ฐ, ๋ธ๋ผ์ฐ์ ๋ ํน์ ์์ฉํ๋ก๊ทธ๋จ ๋๋ ํ์ ์์ฉํ๋ก๊ทธ๋จ๊ณผ ๊ฐ๊ฐ ํต์ ํ ์ ์๊ธฐ ๋๋ฌธ์ ์ฌ๋ฐ๋ฅด๊ฒ ๋์ํ ๊ฒ์
๋๋ค. |
|||
|
|||
### ๊ธฐ์ ์ ์ธ๋ถ์ฌํญ: `root_path` |
|||
|
|||
์์ ์ค๋ช
๋ ๊ฒ๊ณผ ๊ฐ์ด ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ง์ดํธํ๋ ๊ฒฝ์ฐ, FastAPI๋ `root_path`๋ผ๊ณ ํ๋ ASGI ๋ช
์ธ์ ๋งค์ปค๋์ฆ์ ์ฌ์ฉํ์ฌ ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ํ ๋ง์ดํธ ๊ฒฝ๋ก ํต์ ์ ์ฒ๋ฆฌํฉ๋๋ค. |
|||
|
|||
์ด๋ฅผ ํตํด, ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ฌธ์ UI๋ฅผ ์ํด ๊ฒฝ๋ก ์ ๋์ฌ๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค๋ ์ฌ์ค์ ์ธ์งํฉ๋๋ค. |
|||
|
|||
ํ์ ์์ฉํ๋ก๊ทธ๋จ์๋ ์ญ์ ๋ค๋ฅธ ํ์ ์์ฉํ๋ก๊ทธ๋จ์ ๋ง์ดํธํ๋ ๊ฒ์ด ๊ฐ๋ฅํ๋ฉฐ FastAPI๊ฐ ๋ชจ๋ `root_path` ๋ค์ ์๋์ ์ผ๋ก ์ฒ๋ฆฌํ๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ๊ฒ์ ์ฌ๋ฐ๋ฅด๊ฒ ๋์ํ ๊ฒ์
๋๋ค. |
|||
|
|||
`root_path`์ ์ด๊ฒ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด์๋ [ํ๋ก์์ ๋ท๋จ](./behind-a-proxy.md){.internal-link target=_blank} ์น์
์์ ๋ฐฐ์ธ ์ ์์ต๋๋ค. |
Loadingโฆ
Reference in new issue