Skip to content

FastAPI

FastAPI

FastAPI ๐Ÿ› ๏ธ, โ†• ๐ŸŽญ, โฉ ๐Ÿ’ก, โฉ ๐Ÿ“Ÿ, ๐Ÿ”œ ๐Ÿญ

Test Coverage Package version Supported Python versions


๐Ÿงพ: https://fastapi.tiangolo.com

โ„น ๐Ÿ“Ÿ: https://github.com/tiangolo/fastapi


FastAPI ๐Ÿ›, โฉ (โ†•-๐ŸŽญ), ๐Ÿ•ธ ๐Ÿ› ๏ธ ๐Ÿ— ๐Ÿ› ๏ธ โฎ๏ธ ๐Ÿ 3๏ธโƒฃ.8๏ธโƒฃ โž• โš“๏ธ ๐Ÿ”› ๐Ÿฉ ๐Ÿ ๐Ÿ†Ž ๐Ÿ”‘.

๐Ÿ”‘ โš’:

  • โฉ: ๐Ÿ“ถ โ†• ๐ŸŽญ, ๐Ÿ”› ๐Ÿ‡ท๐Ÿ‡ช โฎ๏ธ โœณ & ๐Ÿšถ (๐Ÿ‘ ๐Ÿ’ƒ & Pydantic). 1๏ธโƒฃ โฉ ๐Ÿ ๐Ÿ› ๏ธ ๐Ÿ’ช.
  • โฉ ๐Ÿ“Ÿ: ๐Ÿ“ˆ ๐Ÿš… ๐Ÿ› ๏ธ โš’ ๐Ÿ”ƒ 2๏ธโƒฃ0๏ธโƒฃ0๏ธโƒฃ ๐Ÿ’ฏ 3๏ธโƒฃ0๏ธโƒฃ0๏ธโƒฃ ๐Ÿ’ฏ. *
  • ๐Ÿ‘ฉโ€โคโ€๐Ÿ‘จ ๐Ÿ›: ๐Ÿ“‰ ๐Ÿ”ƒ 4๏ธโƒฃ0๏ธโƒฃ ๐Ÿ’ฏ ๐Ÿ—ฟ (๐Ÿ‘ฉโ€๐Ÿ’ป) ๐Ÿ“‰ โŒ. *
  • ๐Ÿ‹๏ธ: ๐Ÿ‘‘ ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ•โ€๐Ÿฆบ. ๐Ÿ› ๏ธ ๐ŸŒ. ๐ŸŒ˜ ๐Ÿ•ฐ ๐Ÿ› ๏ธ.
  • โฉ: ๐Ÿ”ง โฉ โš™๏ธ & ๐Ÿ’ก. ๐ŸŒ˜ ๐Ÿ•ฐ ๐Ÿ‘‚ ๐Ÿฉบ.
  • ๐Ÿ“: ๐Ÿ“‰ ๐Ÿ“Ÿ โŽ. ๐Ÿ’— โš’ โšช๏ธโžก๏ธ ๐Ÿ”  ๐Ÿ”ข ๐Ÿ“„. ๐Ÿ‘ฉโ€โคโ€๐Ÿ‘จ ๐Ÿ›.
  • ๐Ÿ‹๏ธ: ๐Ÿคš ๐Ÿญ-๐Ÿ”œ ๐Ÿ“Ÿ. โฎ๏ธ ๐Ÿง ๐ŸŽ“ ๐Ÿงพ.
  • ๐Ÿฉ-โš“๏ธ: โš“๏ธ ๐Ÿ”› (& ๐Ÿ• ๐Ÿ”— โฎ๏ธ) ๐Ÿ“‚ ๐Ÿฉ ๐Ÿ”—: ๐Ÿ—„ (โช ๐Ÿ’ญ ๐Ÿฆ) & ๐ŸŽป ๐Ÿ”—.

* โš– โš“๏ธ ๐Ÿ”› ๐Ÿ’ฏ ๐Ÿ”› ๐Ÿ”— ๐Ÿ› ๏ธ ๐Ÿ‰, ๐Ÿ— ๐Ÿญ ๐Ÿˆธ.

๐Ÿ’ฐ

๐ŸŽ ๐Ÿ’ฐ

๐Ÿค”

"[...] ๐Ÿ‘ค โš™๏ธ FastAPI ๐Ÿ“š ๐Ÿ‘ซ ๐Ÿ“†. [...] ๐Ÿ‘ค ๐Ÿค™ ๐Ÿ“† โš™๏ธ โšซ๏ธ ๐ŸŒ ๐Ÿ‘‡ ๐Ÿ‰ โš— ๐Ÿ•โ€๐Ÿฆบ ๐Ÿคธโ€โ™‚. ๐Ÿ‘ซ ๐Ÿ’†โ€โ™‚ ๐Ÿ› ๏ธ ๐Ÿ”˜ ๐Ÿš ๐Ÿ–ฅ ๐Ÿฌ & ๐Ÿ“  ๐Ÿฌ."

๐Ÿงฟ ๐Ÿ‡ต๐Ÿ‡ฐ - ๐Ÿคธโ€โ™‚ (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿ‘ฅ ๐Ÿ› ๏ธ FastAPI ๐Ÿ—ƒ ๐Ÿค– ๐ŸŽ‚ ๐Ÿ’ฝ ๐Ÿ‘ˆ ๐Ÿ’ช ๐Ÿ”ข ๐Ÿšš ๐Ÿ”ฎ. [๐Ÿ‘จ๐Ÿ“›]"

๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ธ๐Ÿ‡ป, ๐Ÿ‘จ๐Ÿ“› ๐Ÿ‘จ๐Ÿ“›, & ๐Ÿ‡ฑ๐Ÿ‡ฐ ๐Ÿ•‰ ๐Ÿ•‰ - ๐Ÿ™ƒ (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿ“บ ๐Ÿ™ ๐Ÿ“ฃ ๐Ÿ“‚-โ„น ๐Ÿš€ ๐Ÿ‘† โš” ๐Ÿงพ ๐ŸŽถ ๐Ÿ› ๏ธ: ๐Ÿ“จโ— [๐Ÿ— โฎ๏ธ FastAPI]"

โœก ๐Ÿ, ๐Ÿ‘– ๐Ÿ‡ช๐Ÿ‡ธ, ๐ŸŒฒ ๐Ÿ - ๐Ÿ“บ (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿ‘ค ๐Ÿคญ ๐ŸŒ• ๐Ÿ˜„ ๐Ÿ”ƒ FastAPI. โšซ๏ธ ๐ŸŽŠ โ—"

โœก ๐Ÿ‡ญ๐Ÿ‡ฐ - ๐Ÿ ๐Ÿ”ข ๐Ÿ“ป ๐Ÿฆ  (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿค™, โšซ๏ธโ” ๐Ÿ‘† โœ”๏ธ ๐Ÿ— ๐Ÿ‘€ ๐Ÿ’Ž ๐Ÿ’  & ๐Ÿ‡ต๐Ÿ‡ฑ. ๐Ÿ“š ๐ŸŒŒ, โšซ๏ธ โšซ๏ธโ” ๐Ÿ‘ค ๐Ÿ’š ๐Ÿค— - โšซ๏ธ ๐Ÿค™ ๐Ÿ˜ ๐Ÿ‘€ ๐Ÿ‘ฑ ๐Ÿ— ๐Ÿ‘ˆ."

โœก ๐Ÿ—„ - ๐Ÿค— ๐Ÿ‘ผ (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿšฅ ๐Ÿ‘† ๐Ÿ‘€ ๐Ÿ’ก 1๏ธโƒฃ ๐Ÿ› ๐Ÿ› ๏ธ ๐Ÿ— ๐ŸŽ‚ ๐Ÿ”—, โœ… ๐Ÿ‘… FastAPI [...] โšซ๏ธ โฉ, โฉ โš™๏ธ & โฉ ๐Ÿ’ก [...]"

"๐Ÿ‘ฅ โœ”๏ธ ๐ŸŽ› ๐Ÿคญ FastAPI ๐Ÿ‘† ๐Ÿ”— [...] ๐Ÿ‘ค ๐Ÿ’ญ ๐Ÿ‘† ๐Ÿ”œ ๐Ÿ’– โšซ๏ธ [...]"

๐Ÿ‡ฑ๐Ÿ‡จ ๐Ÿ‡ธ๐Ÿ‡ฒ - โœก Honnibal - ๐Ÿ’ฅ ๐Ÿ‘ฒ ๐Ÿ•ด - ๐ŸŒˆ ๐Ÿ‘ผ (๐Ÿ‡ฆ๐Ÿ‡ช) - (๐Ÿ‡ฆ๐Ÿ‡ช)

"๐Ÿšฅ ๐Ÿ™† ๐Ÿ‘€ ๐Ÿ— ๐Ÿญ ๐Ÿ ๐Ÿ› ๏ธ, ๐Ÿ‘ค ๐Ÿ”œ ๐Ÿ† ๐Ÿ‘ FastAPI. โšซ๏ธ ๐Ÿ’Ž ๐Ÿ—, ๐Ÿ™… โš™๏ธ & ๐Ÿ† ๐Ÿ› ๏ธ, โšซ๏ธ โœ”๏ธ โ–ถ๏ธ๏ธ ๐Ÿ”‘ ๐Ÿฆฒ ๐Ÿ‘† ๐Ÿ› ๏ธ ๐Ÿฅ‡ ๐Ÿ› ๏ธ ๐ŸŽ› & ๐Ÿš˜ ๐Ÿ“š ๐Ÿง & ๐Ÿ•โ€๐Ÿฆบ โœ… ๐Ÿ‘† ๐Ÿ•น ๐Ÿ”ซ ๐Ÿ‘จโ€๐Ÿ’ป."

๐Ÿ‡น๐Ÿ‡ฆ ๐Ÿฐ - ๐Ÿ“ป (๐Ÿ‡ฆ๐Ÿ‡ช)

๐ŸŽ, FastAPI ๐Ÿ‡ณ๐Ÿ‡จ

๐Ÿšฅ ๐Ÿ‘† ๐Ÿ— โœณ ๐Ÿ“ฑ โš™๏ธ ๐Ÿ“ถ โ†ฉ๏ธ ๐Ÿ•ธ ๐Ÿ› ๏ธ, โœ… ๐Ÿ‘… ๐ŸŽ.

๐ŸŽ FastAPI ๐Ÿฅ ๐Ÿ‘ช. & โšซ๏ธ ๐ŸŽฏ FastAPI ๐Ÿ‡ณ๐Ÿ‡จ. ๐Ÿ‘ถ ๐Ÿ‘ถ ๐Ÿ‘ถ

๐Ÿ“„

๐Ÿ 3๏ธโƒฃ.7๏ธโƒฃ โž•

FastAPI ๐Ÿง ๐Ÿ”› โŒš ๐Ÿ˜:

๐Ÿ‘ทโ€โ™‚

$ pip install fastapi

---> 100%

๐Ÿ‘† ๐Ÿ”œ ๐Ÿ’ช ๐Ÿ”ซ ๐Ÿ’ฝ, ๐Ÿญ โœ… Uvicorn โš–๏ธ Hypercorn.

$ pip install "uvicorn[standard]"

---> 100%

๐Ÿ–ผ

โœ โšซ๏ธ

  • โœ ๐Ÿ“ main.py โฎ๏ธ:
from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}
โš–๏ธ โš™๏ธ async def...

๐Ÿšฅ ๐Ÿ‘† ๐Ÿ“Ÿ โš™๏ธ async / await, โš™๏ธ async def:

from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}

๐Ÿ—’:

๐Ÿšฅ ๐Ÿ‘† ๐Ÿšซ ๐Ÿ’ญ, โœ… _"๐Ÿƒ โ“" _ ๐Ÿ“„ ๐Ÿ”ƒ async & await ๐Ÿฉบ.

๐Ÿƒ โšซ๏ธ

๐Ÿƒ ๐Ÿ’ฝ โฎ๏ธ:

$ uvicorn main:app --reload

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [28720]
INFO:     Started server process [28722]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
๐Ÿ”ƒ ๐Ÿ“‹ uvicorn main:app --reload...

๐Ÿ“‹ uvicorn main:app ๐Ÿ”—:

  • main: ๐Ÿ“ main.py (๐Ÿ "๐Ÿ•น").
  • app: ๐ŸŽš โœ ๐Ÿ”˜ main.py โฎ๏ธ โธ app = FastAPI().
  • --reload: โš’ ๐Ÿ’ฝ โ โฎ๏ธ ๐Ÿ“Ÿ ๐Ÿ”€. ๐Ÿ•ด ๐Ÿ‘‰ ๐Ÿ› ๏ธ.

โœ… โšซ๏ธ

๐Ÿ“‚ ๐Ÿ‘† ๐Ÿ–ฅ http://127.0.0.1:8000/items/5?q=somequery.

๐Ÿ‘† ๐Ÿ”œ ๐Ÿ‘€ ๐ŸŽป ๐Ÿ“จ:

{"item_id": 5, "q": "somequery"}

๐Ÿ‘† โช โœ ๐Ÿ› ๏ธ ๐Ÿ‘ˆ:

  • ๐Ÿ“จ ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ” ๐Ÿ“จ โžก / & /items/{item_id}.
  • ๐Ÿ‘ฏโ€โ™‚๏ธ โžก โœŠ GET ๐Ÿ› ๏ธ (๐Ÿ’ญ ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ” ๐Ÿ‘ฉโ€๐Ÿ”ฌ).
  • โžก /items/{item_id} โœ”๏ธ โžก ๐Ÿ”ข item_id ๐Ÿ‘ˆ ๐Ÿ”œ int.
  • โžก /items/{item_id} โœ”๏ธ ๐Ÿ“ฆ str _๐Ÿ”ข = q.

๐ŸŽ“ ๐Ÿ› ๏ธ ๐Ÿฉบ

๐Ÿ”œ ๐Ÿšถ http://127.0.0.1:8000/docs.

๐Ÿ‘† ๐Ÿ”œ ๐Ÿ‘€ ๐Ÿง ๐ŸŽ“ ๐Ÿ› ๏ธ ๐Ÿงพ (๐Ÿšš ๐Ÿฆ ๐ŸŽš):

Swagger UI

๐ŸŽ› ๐Ÿ› ๏ธ ๐Ÿฉบ

& ๐Ÿ”œ, ๐Ÿšถ http://127.0.0.1:8000/redoc.

๐Ÿ‘† ๐Ÿ”œ ๐Ÿ‘€ ๐ŸŽ› ๐Ÿง ๐Ÿงพ (๐Ÿšš ๐Ÿ“„):

ReDoc

๐Ÿ–ผ โ™ป

๐Ÿ”œ ๐Ÿ”€ ๐Ÿ“ main.py ๐Ÿ“จ ๐Ÿ’ช โšช๏ธโžก๏ธ PUT ๐Ÿ“จ.

๐Ÿ“ฃ ๐Ÿ’ช โš™๏ธ ๐Ÿฉ ๐Ÿ ๐Ÿ†Ž, ๐Ÿ‘ Pydantic.

from typing import Union

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    price: float
    is_offer: Union[bool, None] = None


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}


@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
    return {"item_name": item.name, "item_id": item_id}

๐Ÿ’ฝ ๐Ÿ”œ ๐Ÿ”ƒ ๐Ÿ” (โ†ฉ๏ธ ๐Ÿ‘† ๐Ÿšฎ --reload uvicorn ๐Ÿ“‹ ๐Ÿ”›).

๐ŸŽ“ ๐Ÿ› ๏ธ ๐Ÿฉบ โ™ป

๐Ÿ”œ ๐Ÿšถ http://127.0.0.1:8000/docs.

  • ๐ŸŽ“ ๐Ÿ› ๏ธ ๐Ÿงพ ๐Ÿ”œ ๐Ÿ” โ„น, ๐Ÿ”Œ ๐Ÿ†• ๐Ÿ’ช:

Swagger UI

  • ๐Ÿ–Š ๐Ÿ”› ๐Ÿ”ผ "๐Ÿ”„ โšซ๏ธ ๐Ÿ‘…", โšซ๏ธ โœ” ๐Ÿ‘† ๐Ÿฅง ๐Ÿ”ข & ๐Ÿ”— ๐Ÿ”— โฎ๏ธ ๐Ÿ› ๏ธ:

Swagger UI interaction

  • โคด๏ธ ๐Ÿ–Š ๐Ÿ”› "๐Ÿ› ๏ธ" ๐Ÿ”ผ, ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ”ข ๐Ÿ”œ ๐Ÿ”— โฎ๏ธ ๐Ÿ‘† ๐Ÿ› ๏ธ, ๐Ÿ“จ ๐Ÿ”ข, ๐Ÿคš ๐Ÿ & ๐ŸŽฆ ๐Ÿ‘ซ ๐Ÿ”› ๐Ÿ–ฅ:

Swagger UI interaction

๐ŸŽ› ๐Ÿ› ๏ธ ๐Ÿฉบ โ™ป

& ๐Ÿ”œ, ๐Ÿšถ http://127.0.0.1:8000/redoc.

  • ๐ŸŽ› ๐Ÿงพ ๐Ÿ”œ ๐ŸŽจ ๐Ÿ†• ๐Ÿ”ข ๐Ÿ”ข & ๐Ÿ’ช:

ReDoc

๐ŸŒƒ

๐Ÿ“„, ๐Ÿ‘† ๐Ÿ“ฃ ๐Ÿ• ๐Ÿ†Ž ๐Ÿ”ข, ๐Ÿ’ช, โ™’๏ธ. ๐Ÿ”ข ๐Ÿ”ข.

๐Ÿ‘† ๐Ÿ‘ˆ โฎ๏ธ ๐Ÿฉ ๐Ÿ› ๐Ÿ ๐Ÿ†Ž.

๐Ÿ‘† ๐Ÿšซ โœ”๏ธ ๐Ÿ’ก ๐Ÿ†• โ•, ๐Ÿ‘ฉโ€๐Ÿ”ฌ โš–๏ธ ๐ŸŽ“ ๐ŸŽฏ ๐Ÿ—ƒ, โ™’๏ธ.

๐Ÿฉ ๐Ÿ 3๏ธโƒฃ.7๏ธโƒฃ โž•.

๐Ÿ–ผ, int:

item_id: int

โš–๏ธ ๐ŸŒ– ๐Ÿ— Item ๐Ÿท:

item: Item

...& โฎ๏ธ ๐Ÿ‘ˆ ๐Ÿ‘ ๐Ÿ“„ ๐Ÿ‘† ๐Ÿคš:

  • ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ•โ€๐Ÿฆบ, ๐Ÿ”Œ:
    • ๐Ÿ› ๏ธ.
    • ๐Ÿ†Ž โœ….
  • ๐Ÿ”ฌ ๐Ÿ’ฝ:
    • ๐Ÿง & ๐Ÿ†‘ โŒ ๐Ÿ•โ” ๐Ÿ“Š โŒ.
    • ๐Ÿ”ฌ ๐Ÿ™‡ ๐Ÿฆ ๐ŸŽป ๐ŸŽš.
  • ๐Ÿ› ๏ธ ๐Ÿ”ข ๐Ÿ’ฝ: ๐Ÿ‘Ÿ โšช๏ธโžก๏ธ ๐Ÿ•ธ ๐Ÿ ๐Ÿ’ฝ & ๐Ÿ†Ž. ๐Ÿ‘‚ โšช๏ธโžก๏ธ:
    • ๐ŸŽป.
    • โžก ๐Ÿ”ข.
    • ๐Ÿ”ข ๐Ÿ”ข.
    • ๐Ÿช.
    • ๐ŸŽš.
    • ๐Ÿ“จ.
    • ๐Ÿ“.
  • ๐Ÿ› ๏ธ ๐Ÿ”ข ๐Ÿ“Š: ๐Ÿ—œ โšช๏ธโžก๏ธ ๐Ÿ ๐Ÿ’ฝ & ๐Ÿ†Ž ๐Ÿ•ธ ๐Ÿ’ฝ (๐ŸŽป):
    • ๐Ÿ—œ ๐Ÿ ๐Ÿ†Ž (str, int, float, bool, list, โ™’๏ธ).
    • datetime ๐ŸŽš.
    • UUID ๐ŸŽš.
    • ๐Ÿ’ฝ ๐Ÿท.
    • ...& ๐Ÿ“š ๐ŸŒ–.
  • ๐Ÿง ๐ŸŽ“ ๐Ÿ› ๏ธ ๐Ÿงพ, ๐Ÿ”Œ 2๏ธโƒฃ ๐ŸŽ› ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ”ข:
    • ๐Ÿฆ ๐ŸŽš.
    • ๐Ÿ“„.

๐Ÿ‘Ÿ ๐Ÿ”™ โฎ๏ธ ๐Ÿ“Ÿ ๐Ÿ–ผ, FastAPI ๐Ÿ”œ:

  • โœ” ๐Ÿ‘ˆ ๐Ÿ“ค item_id โžก GET & PUT ๐Ÿ“จ.
  • โœ” ๐Ÿ‘ˆ item_id ๐Ÿ†Ž int GET & PUT ๐Ÿ“จ.
    • ๐Ÿšฅ โšซ๏ธ ๐Ÿšซ, ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ”œ ๐Ÿ‘€ โš , ๐Ÿ†‘ โŒ.
  • โœ… ๐Ÿšฅ ๐Ÿ“ค ๐Ÿ“ฆ ๐Ÿ”ข ๐Ÿ”ข ๐Ÿ“› q ( http://127.0.0.1:8000/items/foo?q=somequery) GET ๐Ÿ“จ.
    • q ๐Ÿ”ข ๐Ÿ“ฃ โฎ๏ธ = None, โšซ๏ธ ๐Ÿ“ฆ.
    • ๐Ÿต None โšซ๏ธ ๐Ÿ”œ ๐Ÿšš (๐Ÿ’ช ๐Ÿ’ผ โฎ๏ธ PUT).
  • PUT ๐Ÿ“จ /items/{item_id}, โœ ๐Ÿ’ช ๐ŸŽป:
    • โœ… ๐Ÿ‘ˆ โšซ๏ธ โœ”๏ธ โœ” ๐Ÿ”ข name ๐Ÿ‘ˆ ๐Ÿ”œ str.
    • โœ… ๐Ÿ‘ˆ โšซ๏ธ โœ”๏ธ โœ” ๐Ÿ”ข price ๐Ÿ‘ˆ โœ”๏ธ float.
    • โœ… ๐Ÿ‘ˆ โšซ๏ธ โœ”๏ธ ๐Ÿ“ฆ ๐Ÿ”ข is_offer, ๐Ÿ‘ˆ ๐Ÿ”œ bool, ๐Ÿšฅ ๐ŸŽ.
    • ๐ŸŒ ๐Ÿ‘‰ ๐Ÿ”œ ๐Ÿ‘ท ๐Ÿ™‡ ๐Ÿฆ ๐ŸŽป ๐ŸŽš.
  • ๐Ÿ—œ โšช๏ธโžก๏ธ & ๐ŸŽป ๐Ÿ”.
  • ๐Ÿ“„ ๐ŸŒ โฎ๏ธ ๐Ÿ—„, ๐Ÿ‘ˆ ๐Ÿ’ช โš™๏ธ:
    • ๐ŸŽ“ ๐Ÿงพ โš™๏ธ.
    • ๐Ÿง ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ“Ÿ โšก โš™๏ธ, ๐Ÿ“š ๐Ÿ‡ช๐Ÿ‡ธ.
  • ๐Ÿšš 2๏ธโƒฃ ๐ŸŽ“ ๐Ÿงพ ๐Ÿ•ธ ๐Ÿ”ข ๐Ÿ”—.

๐Ÿ‘ฅ ๐Ÿ–Œ ๐Ÿงฝ, โœ‹๏ธ ๐Ÿ‘† โช ๐Ÿคš ๐Ÿ’ญ โ” โšซ๏ธ ๐ŸŒ ๐Ÿ‘ท.

๐Ÿ”„ ๐Ÿ”€ โธ โฎ๏ธ:

    return {"item_name": item.name, "item_id": item_id}

...โšช๏ธโžก๏ธ:

        ... "item_name": item.name ...

...:

        ... "item_price": item.price ...

...& ๐Ÿ‘€ โ” ๐Ÿ‘† ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ”œ ๐Ÿš˜-๐Ÿ ๐Ÿ”ข & ๐Ÿ’ญ ๐Ÿ‘ซ ๐Ÿ†Ž:

editor support

๐ŸŒ… ๐Ÿ ๐Ÿ–ผ ๐Ÿ”Œ ๐ŸŒ… โš’, ๐Ÿ‘€ ๐Ÿ”ฐ - ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿฆฎ.

๐Ÿš˜ ๐Ÿšจ: ๐Ÿ”ฐ - ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿฆฎ ๐Ÿ”Œ:

  • ๐Ÿ“„ ๐Ÿ”ข โšช๏ธโžก๏ธ ๐ŸŽ ๐ŸŽ ๐Ÿฅ‰: ๐ŸŽš, ๐Ÿช, ๐Ÿ“จ ๐Ÿ‘ & ๐Ÿ“.
  • โ” โš’ ๐Ÿ”ฌ โš› maximum_length โš–๏ธ regex.
  • ๐Ÿ“ถ ๐Ÿ‹๏ธ & โฉ โš™๏ธ ๐Ÿ”— ๐Ÿ’‰ โš™๏ธ.
  • ๐Ÿ’‚โ€โ™‚ & ๐Ÿค, โœ… ๐Ÿ•โ€๐Ÿฆบ Oauth2๏ธโƒฃ โฎ๏ธ ๐Ÿฅ™ ๐Ÿค & ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ” ๐Ÿ”ฐ ๐Ÿ”.
  • ๐ŸŒ… ๐Ÿง (โœ‹๏ธ ๐Ÿ˜จ โฉ) โš’ ๐Ÿ“ฃ ๐Ÿ™‡ ๐Ÿฆ ๐ŸŽป ๐Ÿท (๐Ÿ‘ Pydantic).
  • ๐Ÿ•น ๐Ÿ› ๏ธ โฎ๏ธ ๐Ÿ“ & ๐ŸŽ ๐Ÿ—ƒ.
  • ๐Ÿ“š โž• โš’ (๐Ÿ‘ ๐Ÿ’ƒ):
    • ** *๏ธโƒฃ **
    • ๐Ÿ“ถ โฉ ๐Ÿ’ฏ โš“๏ธ ๐Ÿ”› ๐Ÿ‡ธ๐Ÿ‡ฒ & pytest
    • โšœ
    • ๐Ÿช ๐ŸŽ‰
    • ...& ๐ŸŒ–.

๐ŸŽญ

๐Ÿ”ฌ ๐Ÿ‡ธ๐Ÿ‡ฒ ๐Ÿ“‡ ๐ŸŽฆ FastAPI ๐Ÿˆธ ๐Ÿƒโ€โ™‚ ๐Ÿ”ฝ Uvicorn 1๏ธโƒฃ โฉ ๐Ÿ ๐Ÿ› ๏ธ ๐Ÿ’ช, ๐Ÿ•ด ๐Ÿ”› ๐Ÿ’ƒ & Uvicorn ๐Ÿ‘ซ (โš™๏ธ ๐Ÿ”˜ FastAPI). (*)

๐Ÿค” ๐ŸŒ– ๐Ÿ”ƒ โšซ๏ธ, ๐Ÿ‘€ ๐Ÿ“„ ๐Ÿ“‡.

๐Ÿ“ฆ ๐Ÿ”—

โš™๏ธ Pydantic:

โš™๏ธ ๐Ÿ’ƒ:

  • httpx - โœ” ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š โš™๏ธ TestClient.
  • jinja2 - โœ” ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š โš™๏ธ ๐Ÿ”ข ๐Ÿ“„ ๐Ÿ“ณ.
  • python-multipart - โœ” ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š ๐Ÿ•โ€๐Ÿฆบ ๐Ÿ“จ "โœ", โฎ๏ธ request.form().
  • itsdangerous - โœ” SessionMiddleware ๐Ÿ•โ€๐Ÿฆบ.
  • pyyaml - โœ” ๐Ÿ’ƒ SchemaGenerator ๐Ÿ•โ€๐Ÿฆบ (๐Ÿ‘† ๐ŸŽฒ ๐Ÿšซ ๐Ÿ’ช โšซ๏ธ โฎ๏ธ FastAPI).
  • ujson - โœ” ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š โš™๏ธ UJSONResponse.

โš™๏ธ FastAPI / ๐Ÿ’ƒ:

  • uvicorn - ๐Ÿ’ฝ ๐Ÿ‘ˆ ๐Ÿ“ & ๐Ÿฆ ๐Ÿ‘† ๐Ÿˆธ.
  • orjson - โœ” ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š โš™๏ธ ORJSONResponse.

๐Ÿ‘† ๐Ÿ’ช โŽ ๐ŸŒ ๐Ÿ‘ซ โฎ๏ธ pip install "fastapi[all]".

๐Ÿ›‚

๐Ÿ‘‰ ๐Ÿ— ยฎ ๐Ÿ”ฝ โš– ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ›‚.