Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/fastapi-cli.md` (#12515)

pull/12688/head
๊น€์†Œ์—ฐ 5 months ago
committed by GitHub
parent
commit
5c33269419
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 83
      docs/ko/docs/fastapi-cli.md

83
docs/ko/docs/fastapi-cli.md

@ -0,0 +1,83 @@
# FastAPI CLI
**FastAPI CLI**๋Š” FastAPI ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•˜๊ณ , ํ”„๋กœ์ ํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ์ปค๋งจ๋“œ ๋ผ์ธ ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค.
FastAPI๋ฅผ ์„ค์น˜ํ•  ๋•Œ (์˜ˆ: `pip install "fastapi[standard]"` ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ), `fastapi-cli`๋ผ๋Š” ํŒจํ‚ค์ง€๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์ด ํŒจํ‚ค์ง€๋Š” ํ„ฐ๋ฏธ๋„์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” `fastapi` ๋ช…๋ น์–ด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
๊ฐœ๋ฐœ์šฉ์œผ๋กœ FastAPI ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด `fastapi dev` ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<div class="termy">
```console
$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:single">main.py</u>
<font color="#3465A4">INFO </font> Using path <font color="#3465A4">main.py</font>
<font color="#3465A4">INFO </font> Resolved absolute path <font color="#75507B">/home/user/code/awesomeapp/</font><font color="#AD7FA8">main.py</font>
<font color="#3465A4">INFO </font> Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files
<font color="#3465A4">INFO </font> Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font>
โ•ญโ”€ <font color="#8AE234"><b>Python module file</b></font> โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ ๐Ÿ main.py โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
<font color="#3465A4">INFO </font> Importing module <font color="#4E9A06">main</font>
<font color="#3465A4">INFO </font> Found importable FastAPI app
โ•ญโ”€ <font color="#8AE234"><b>Importable FastAPI app</b></font> โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ <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> โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
<font color="#3465A4">INFO </font> Using import string <font color="#8AE234"><b>main:app</b></font>
<span style="background-color:#C4A000"><font color="#2E3436">โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ FastAPI CLI - Development mode โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ Serving at: http://127.0.0.1:8000 โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ API docs: http://127.0.0.1:8000/docs โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ Running in development mode, for production use: โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ </font></span><span style="background-color:#C4A000"><font color="#555753"><b>fastapi run</b></font></span><span style="background-color:#C4A000"><font color="#2E3436"> โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ”‚ โ”‚</font></span>
<span style="background-color:#C4A000"><font color="#2E3436">โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ</font></span>
<font color="#4E9A06">INFO</font>: Will watch for changes in these directories: [&apos;/home/user/code/awesomeapp&apos;]
<font color="#4E9A06">INFO</font>: Uvicorn running on <b>http://127.0.0.1:8000</b> (Press CTRL+C to quit)
<font color="#4E9A06">INFO</font>: Started reloader process [<font color="#34E2E2"><b>2265862</b></font>] using <font color="#34E2E2"><b>WatchFiles</b></font>
<font color="#4E9A06">INFO</font>: Started server process [<font color="#06989A">2265873</font>]
<font color="#4E9A06">INFO</font>: Waiting for application startup.
<font color="#4E9A06">INFO</font>: Application startup complete.
```
</div>
`fastapi`๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ๋ช…๋ น์–ด ํ”„๋กœ๊ทธ๋žจ์€ **FastAPI CLI**์ž…๋‹ˆ๋‹ค.
FastAPI CLI๋Š” Python ํ”„๋กœ๊ทธ๋žจ์˜ ๊ฒฝ๋กœ(์˜ˆ: `main.py`)๋ฅผ ์ธ์ˆ˜๋กœ ๋ฐ›์•„, `FastAPI` ์ธ์Šคํ„ด์Šค(์ผ๋ฐ˜์ ์œผ๋กœ `app`์œผ๋กœ ๋ช…๋ช…)๋ฅผ ์ž๋™์œผ๋กœ ๊ฐ์ง€ํ•˜๊ณ  ์˜ฌ๋ฐ”๋ฅธ ์ž„ํฌํŠธ ๊ณผ์ •์„ ๊ฒฐ์ •ํ•œ ํ›„ ์ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ๋Š” `fastapi run` ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๐Ÿš€
๋‚ด๋ถ€์ ์œผ๋กœ, **FastAPI CLI**๋Š” ๊ณ ์„ฑ๋Šฅ์˜, ํ”„๋กœ๋•์…˜์— ์ ํ•ฉํ•œ, ASGI ์„œ๋ฒ„์ธ <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ˜Ž
## `fastapi dev`
`fastapi dev` ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ๊ฐœ๋ฐœ ๋ชจ๋“œ๊ฐ€ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค.
๊ธฐ๋ณธ์ ์œผ๋กœ **์ž๋™ ์žฌ์‹œ์ž‘(auto-reload)** ๊ธฐ๋Šฅ์ด ํ™œ์„ฑํ™”๋˜์–ด, ์ฝ”๋“œ์— ๋ณ€๊ฒฝ์ด ์ƒ๊ธฐ๋ฉด ์„œ๋ฒ„๋ฅผ ์ž๋™์œผ๋กœ ๋‹ค์‹œ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ๊ธฐ๋Šฅ์€ ๋ฆฌ์†Œ์Šค๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋ฉฐ, ๋น„ํ™œ์„ฑํ™”ํ–ˆ์„ ๋•Œ๋ณด๋‹ค ์•ˆ์ •์„ฑ์ด ๋–จ์–ด์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ๋งŒ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์„œ๋ฒ„๋Š” ์ปดํ“จํ„ฐ๊ฐ€ ์ž์ฒด์ ์œผ๋กœ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋Š” IP ์ฃผ์†Œ(`localhost`)์ธ `127.0.0.1`์—์„œ ์—ฐ๊ฒฐ์„ ๋Œ€๊ธฐํ•ฉ๋‹ˆ๋‹ค.
## `fastapi run`
`fastapi run` ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ํ”„๋กœ๋•์…˜ ๋ชจ๋“œ๋กœ FastAPI๊ฐ€ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค.
๊ธฐ๋ณธ์ ์œผ๋กœ **์ž๋™ ์žฌ์‹œ์ž‘(auto-reload)** ๊ธฐ๋Šฅ์ด ๋น„ํ™œ์„ฑํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  IP ์ฃผ์†Œ์ธ `0.0.0.0`์—์„œ ์—ฐ๊ฒฐ์„ ๋Œ€๊ธฐํ•˜๋ฏ€๋กœ ํ•ด๋‹น ์ปดํ“จํ„ฐ์™€ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ์‚ฌ๋žŒ์ด ๊ณต๊ฐœ์ ์œผ๋กœ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ์ปจํ…Œ์ด๋„ˆ์™€ ๊ฐ™์€ ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ์‹์— ๋”ฐ๋ผ ๋‹ค๋ฅด์ง€๋งŒ, ๋Œ€๋ถ€๋ถ„ "์ข…๋ฃŒ ํ”„๋ก์‹œ(termination proxy)"๋ฅผ ํ™œ์šฉํ•ด HTTPS๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋ฐฐํฌ ์„œ๋น„์Šค ์ œ๊ณต์ž๊ฐ€ ์ด ์ž‘์—…์„ ๋Œ€์‹  ์ฒ˜๋ฆฌํ•ด์ค„ ์ˆ˜๋„ ์žˆ๊ณ , ์ง์ ‘ ์„ค์ •ํ•ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
/// tip
์ž์„ธํ•œ ๋‚ด์šฉ์€ [deployment documentation](deployment/index.md){.internal-link target=\_blank}์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
///
Loadingโ€ฆ
Cancel
Save