Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/tutorial/debugging.md` (#5695)

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]>
pull/4492/merge
JungWooGeon 1 year ago
committed by GitHub
parent
commit
bfd6060996
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 112
      docs/ko/docs/tutorial/debugging.md

112
docs/ko/docs/tutorial/debugging.md

@ -0,0 +1,112 @@
# ๋””๋ฒ„๊น…
์˜ˆ๋ฅผ ๋“ค๋ฉด Visual Studio Code ๋˜๋Š” PyCharm์„ ์‚ฌ์šฉํ•˜์—ฌ ํŽธ์ง‘๊ธฐ์—์„œ ๋””๋ฒ„๊ฑฐ๋ฅผ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
## `uvicorn` ํ˜ธ์ถœ
FastAPI ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ `uvicorn`์„ ์ง์ ‘ ์ž„ํฌํŠธํ•˜์—ฌ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค
```Python hl_lines="1 15"
{!../../../docs_src/debugging/tutorial001.py!}
```
### `__name__ == "__main__"` ์— ๋Œ€ํ•˜์—ฌ
`__name__ == "__main__"`์˜ ์ฃผ์š” ๋ชฉ์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŒŒ์ผ์ด ํ˜ธ์ถœ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ผ๋ถ€ ์ฝ”๋“œ๋ฅผ ๊ฐ–๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
<div class="termy">
```console
$ python myapp.py
```
</div>
๊ทธ๋Ÿฌ๋‚˜ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‹ค๋ฅธ ํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ฌ ๋•Œ๋Š” ํ˜ธ์ถœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
```Python
from myapp import app
```
#### ์ถ”๊ฐ€ ์„ธ๋ถ€์‚ฌํ•ญ
ํŒŒ์ผ ์ด๋ฆ„์ด `myapp.py`๋ผ๊ณ  ๊ฐ€์ •ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‹คํ–‰ํ•˜๋ฉด
<div class="termy">
```console
$ python myapp.py
```
</div>
Python์— ์˜ํ•ด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋œ ํŒŒ์ผ์˜ ๋‚ด๋ถ€ ๋ณ€์ˆ˜ `__name__`์€ ๋ฌธ์ž์—ด `"__main__"`์„ ๊ฐ’์œผ๋กœ ๊ฐ–๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ ์„น์…˜
```Python
uvicorn.run(app, host="0.0.0.0", port=8000)
```
์ด ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
---
ํ•ด๋‹น ๋ชจ๋“ˆ(ํŒŒ์ผ)์„ ๊ฐ€์ ธ์˜ค๋ฉด ์ด๋Ÿฐ ์ผ์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค
๊ทธ๋ž˜์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ํŒŒ์ผ `importer.py`๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ:
```Python
from myapp import app
# Some more code
```
์ด ๊ฒฝ์šฐ `myapp.py` ๋‚ด๋ถ€์˜ ์ž๋™ ๋ณ€์ˆ˜์—๋Š” ๊ฐ’์ด `"__main__"`์ธ ๋ณ€์ˆ˜ `__name__`์ด ์—†์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ ๋‹ค์Œ ํ–‰
```Python
uvicorn.run(app, host="0.0.0.0", port=8000)
```
์€ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
!!! info "์ •๋ณด"
์ž์„ธํ•œ ๋‚ด์šฉ์€ <a href="https://docs.python.org/3/library/__main__.html" class="external-link" target="_blank">๊ณต์‹ Python ๋ฌธ์„œ</a>๋ฅผ ํ™•์ธํ•˜์„ธ์š”
## ๋””๋ฒ„๊ฑฐ๋กœ ์ฝ”๋“œ ์‹คํ–‰
์ฝ”๋“œ์—์„œ ์ง์ ‘ Uvicorn ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋””๋ฒ„๊ฑฐ์—์„œ ์ง์ ‘ Python ํ”„๋กœ๊ทธ๋žจ(FastAPI ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์„ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
---
์˜ˆ๋ฅผ ๋“ค์–ด Visual Studio Code์—์„œ ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
* "Debug" ํŒจ๋„๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
* "Add configuration...".
* "Python"์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
* "`Python: Current File (Integrated Terminal)`" ์˜ต์…˜์œผ๋กœ ๋””๋ฒ„๊ฑฐ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋Ÿฐ ๋‹ค์Œ **FastAPI** ์ฝ”๋“œ๋กœ ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ์ค‘๋‹จ์  ๋“ฑ์—์„œ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.
๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
<img src="/img/tutorial/debugging/image01.png">
---
Pycharm์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
* "Run" ๋ฉ”๋‰ด๋ฅผ ์—ฝ๋‹ˆ๋‹ค
* "Debug..." ์˜ต์…˜์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
* ๊ทธ๋Ÿฌ๋ฉด ์ƒํ™ฉ์— ๋งž๋Š” ๋ฉ”๋‰ด๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.
* ๋””๋ฒ„๊ทธํ•  ํŒŒ์ผ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค(์ด ๊ฒฝ์šฐ `main.py`).
๊ทธ๋Ÿฐ ๋‹ค์Œ **FastAPI** ์ฝ”๋“œ๋กœ ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ์ค‘๋‹จ์  ๋“ฑ์—์„œ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.
๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
<img src="/img/tutorial/debugging/image02.png">
Loadingโ€ฆ
Cancel
Save