Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/tutorial/request-forms.md` (#13003)

pull/13018/head
hy.lee 4 months ago
committed by GitHub
parent
commit
5480386e39
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 74
      docs/ko/docs/tutorial/request-forms.md

74
docs/ko/docs/tutorial/request-forms.md

@ -0,0 +1,74 @@
# ํผ ๋ฐ์ดํ„ฐ
JSON ๋Œ€์‹  ํผ ํ•„๋“œ๋ฅผ ๋ฐ›์•„์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ `Form`์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
/// info | ์ •๋ณด
ํผ์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด, ๋จผ์ € <a href="https://github.com/Kludex/python-multipart" class="external-link" target="_blank">`python-multipart`</a>๋ฅผ ์„ค์น˜ํ•˜์„ธ์š”.
[๊ฐ€์ƒ ํ™˜๊ฒฝ](../virtual-environments.md){.internal-link target=_blank}์„ ์ƒ์„ฑํ•˜๊ณ  ํ™œ์„ฑํ™”ํ•œ ๋‹ค์Œ, ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
```console
$ pip install python-multipart
```
///
## `Form` ์ž„ํฌํŠธํ•˜๊ธฐ
`fastapi`์—์„œ `Form`์„ ์ž„ํฌํŠธํ•ฉ๋‹ˆ๋‹ค:
{* ../../docs_src/request_forms/tutorial001_an_py39.py hl[3] *}
## `Form` ๋งค๊ฐœ๋ณ€์ˆ˜ ์ •์˜ํ•˜๊ธฐ
`Body` ๋˜๋Š” `Query`์™€ ๋™์ผํ•œ ๋ฐฉ์‹์œผ๋กœ ํผ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค:
{* ../../docs_src/request_forms/tutorial001_an_py39.py hl[9] *}
์˜ˆ๋ฅผ ๋“ค์–ด, OAuth2 ์‚ฌ์–‘์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜("ํŒจ์Šค์›Œ๋“œ ํ”Œ๋กœ์šฐ"๋ผ๊ณ  ํ•จ)๋กœ `username`๊ณผ `password`๋ฅผ ํผ ํ•„๋“œ๋กœ ๋ณด๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
<abbr title="specification">์‚ฌ์–‘</abbr>์—์„œ๋Š” ํ•„๋“œ ์ด๋ฆ„์ด `username` ๋ฐ `password`๋กœ ์ •ํ™•ํ•˜๊ฒŒ ๋ช…๋ช…๋˜์–ด์•ผ ํ•˜๊ณ , JSON์ด ์•„๋‹Œ ํผ ํ•„๋“œ๋กœ ์ „์†กํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
`Form`์„ ์‚ฌ์šฉํ•˜๋ฉด ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ, ์˜ˆ์ œ, ๋ณ„์นญ(์˜ˆ: `username` ๋Œ€์‹  `user-name`) ๋“ฑ์„ ํฌํ•จํ•˜์—ฌ `Body`(๋ฐ `Query`, `Path`, `Cookie`)์™€ ๋™์ผํ•œ ๊ตฌ์„ฑ์„ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
/// info | ์ •๋ณด
`Form`์€ `Body`์—์„œ ์ง์ ‘ ์ƒ์†๋˜๋Š” ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.
///
/// tip | ํŒ
ํผ ๋ณธ๋ฌธ์„ ์„ ์–ธํ•  ๋•Œ, ํผ์ด ์—†์œผ๋ฉด ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜๋‚˜ ๋ณธ๋ฌธ(JSON) ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ํ•ด์„(interpret)๋˜๊ธฐ ๋•Œ๋ฌธ์— `Form`์„ ๋ช…์‹œ์ ์œผ๋กœ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
///
## "ํผ ํ•„๋“œ"์— ๋Œ€ํ•ด
HTML ํผ(`<form></form>`)์ด ๋ฐ์ดํ„ฐ๋ฅผ ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š” ๋ฐฉ์‹์€ ์ผ๋ฐ˜์ ์œผ๋กœ ํ•ด๋‹น ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด "ํŠน์ˆ˜" ์ธ์ฝ”๋”ฉ์„ ์‚ฌ์šฉํ•˜๋ฉฐ, ์ด๋Š” JSON๊ณผ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.
**FastAPI**๋Š” JSON ๋Œ€์‹  ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์—์„œ ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค.
/// note | ๊ธฐ์ˆ  ์„ธ๋ถ€์‚ฌํ•ญ
ํผ์˜ ๋ฐ์ดํ„ฐ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ "๋ฏธ๋””์–ด ์œ ํ˜•(media type)" `application/x-www-form-urlencoded`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ ํผ์— ํŒŒ์ผ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ, `multipart/form-data`๋กœ ์ธ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์žฅ์—์„œ ํŒŒ์ผ ์ฒ˜๋ฆฌ์— ๋Œ€ํ•ด ์ฝ์„ ๊ฒ๋‹ˆ๋‹ค.
์ด๋Ÿฌํ•œ ์ธ์ฝ”๋”ฉ ๋ฐ ํผ ํ•„๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ๊ณ  ์‹ถ๋‹ค๋ฉด, <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST" class="external-link" target="_blank"><code>POST</code>์— ๋Œ€ํ•œ <abbr title="Mozilla Developer Network">MDN</a> ์›น ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
///
/// warning | ๊ฒฝ๊ณ 
*๊ฒฝ๋กœ ์ž‘์—…*์—์„œ ์—ฌ๋Ÿฌ `Form` ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, JSON์œผ๋กœ ์ˆ˜์‹ ํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜๋Š” `Body` ํ•„๋“œ์™€ ํ•จ๊ป˜ ์„ ์–ธํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์š”์ฒญ ๋ณธ๋ฌธ์€ `application/json` ๋Œ€์‹ ์— `application/x-www-form-urlencoded`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์ฝ”๋”ฉ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
์ด๋Š” **FastAPI**์˜ ์ œํ•œ ์‚ฌํ•ญ์ด ์•„๋‹ˆ๋ฉฐ HTTP ํ”„๋กœํ† ์ฝœ์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค.
///
## ์š”์•ฝ
ํผ ๋ฐ์ดํ„ฐ ์ž…๋ ฅ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋ ค๋ฉด `Form`์„ ์‚ฌ์šฉํ•˜์„ธ์š”.
Loadingโ€ฆ
Cancel
Save