Skip to content

โž• ๐Ÿ’ฝ ๐Ÿ†Ž

๐Ÿ†™ ๐Ÿ”œ, ๐Ÿ‘† โœ”๏ธ โš™๏ธ โš  ๐Ÿ“Š ๐Ÿ†Ž, ๐Ÿ’–:

  • int
  • float
  • str
  • bool

โœ‹๏ธ ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ ๐ŸŒ… ๐Ÿ— ๐Ÿ“Š ๐Ÿ†Ž.

& ๐Ÿ‘† ๐Ÿ”œ โœ”๏ธ ๐ŸŽ โš’ ๐Ÿ‘€ ๐Ÿ†™ ๐Ÿ”œ:

  • ๐Ÿ‘‘ ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ•โ€๐Ÿฆบ.
  • ๐Ÿ’ฝ ๐Ÿ› ๏ธ โšช๏ธโžก๏ธ ๐Ÿ“จ ๐Ÿ“จ.
  • ๐Ÿ’ฝ ๐Ÿ› ๏ธ ๐Ÿ“จ ๐Ÿ’ฝ.
  • ๐Ÿ’ฝ ๐Ÿ”ฌ.
  • ๐Ÿง โœ & ๐Ÿงพ.

๐ŸŽ ๐Ÿ’ฝ ๐Ÿ†Ž

๐Ÿ“ฅ ๐ŸŒ– ๐Ÿ“Š ๐Ÿ†Ž ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ:

  • UUID:
    • ๐Ÿฉ "โญ ๐Ÿ˜ ๐Ÿ†”", โš  ๐Ÿ†” ๐Ÿ“š ๐Ÿ’ฝ & โš™๏ธ.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐ŸŽจ str.
  • datetime.datetime:
    • ๐Ÿ datetime.datetime.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐ŸŽจ str ๐Ÿ’พ 8๏ธโƒฃ6๏ธโƒฃ0๏ธโƒฃ1๏ธโƒฃ ๐Ÿ“, ๐Ÿ’–: 2008-09-15T15:53:00+05:00.
  • datetime.date:
    • ๐Ÿ datetime.date.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐ŸŽจ str ๐Ÿ’พ 8๏ธโƒฃ6๏ธโƒฃ0๏ธโƒฃ1๏ธโƒฃ ๐Ÿ“, ๐Ÿ’–: 2008-09-15.
  • datetime.time:
    • ๐Ÿ datetime.time.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐ŸŽจ str ๐Ÿ’พ 8๏ธโƒฃ6๏ธโƒฃ0๏ธโƒฃ1๏ธโƒฃ ๐Ÿ“, ๐Ÿ’–: 14:23:55.003.
  • datetime.timedelta:
    • ๐Ÿ datetime.timedelta.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐ŸŽจ float ๐ŸŒ ๐Ÿฅˆ.
    • Pydantic โœ” ๐ŸŽฆ โšซ๏ธ "๐Ÿ’พ 8๏ธโƒฃ6๏ธโƒฃ0๏ธโƒฃ1๏ธโƒฃ ๐Ÿ•ฐ โž• ๐Ÿ”ข", ๐Ÿ‘€ ๐Ÿฉบ ๐ŸŒ… โ„น.
  • frozenset:
    • ๐Ÿ“จ & ๐Ÿ“จ, ๐Ÿ˜ฅ ๐ŸŽ set:
      • ๐Ÿ“จ, ๐Ÿ“‡ ๐Ÿ”œ โœ, โŽ โŽ & ๐Ÿญ โšซ๏ธ set.
      • ๐Ÿ“จ, set ๐Ÿ”œ ๐Ÿ—œ list.
      • ๐Ÿ— ๐Ÿ”— ๐Ÿ”œ โœ” ๐Ÿ‘ˆ set ๐Ÿ’ฒ ๐Ÿ˜ (โš™๏ธ ๐ŸŽป ๐Ÿ”— uniqueItems).
  • bytes:
    • ๐Ÿฉ ๐Ÿ bytes.
    • ๐Ÿ“จ & ๐Ÿ“จ ๐Ÿ”œ ๐Ÿ˜ฅ str.
    • ๐Ÿ— ๐Ÿ”— ๐Ÿ”œ โœ” ๐Ÿ‘ˆ โšซ๏ธ str โฎ๏ธ binary "๐Ÿ“".
  • Decimal:
    • ๐Ÿฉ ๐Ÿ Decimal.
    • ๐Ÿ“จ & ๐Ÿ“จ, ๐Ÿต ๐ŸŽ float.
  • ๐Ÿ‘† ๐Ÿ’ช โœ… ๐ŸŒ โ˜‘ Pydantic ๐Ÿ“Š ๐Ÿ†Ž ๐Ÿ“ฅ: Pydantic ๐Ÿ“Š ๐Ÿ†Ž.

๐Ÿ–ผ

๐Ÿ“ฅ ๐Ÿ–ผ โžก ๐Ÿ› ๏ธ โฎ๏ธ ๐Ÿ”ข โš™๏ธ ๐Ÿ”› ๐Ÿ†Ž.

from datetime import datetime, time, timedelta
from typing import Union
from uuid import UUID

from fastapi import Body, FastAPI

app = FastAPI()


@app.put("/items/{item_id}")
async def read_items(
    item_id: UUID,
    start_datetime: Union[datetime, None] = Body(default=None),
    end_datetime: Union[datetime, None] = Body(default=None),
    repeat_at: Union[time, None] = Body(default=None),
    process_after: Union[timedelta, None] = Body(default=None),
):
    start_process = start_datetime + process_after
    duration = end_datetime - start_process
    return {
        "item_id": item_id,
        "start_datetime": start_datetime,
        "end_datetime": end_datetime,
        "repeat_at": repeat_at,
        "process_after": process_after,
        "start_process": start_process,
        "duration": duration,
    }
from datetime import datetime, time, timedelta
from uuid import UUID

from fastapi import Body, FastAPI

app = FastAPI()


@app.put("/items/{item_id}")
async def read_items(
    item_id: UUID,
    start_datetime: datetime | None = Body(default=None),
    end_datetime: datetime | None = Body(default=None),
    repeat_at: time | None = Body(default=None),
    process_after: timedelta | None = Body(default=None),
):
    start_process = start_datetime + process_after
    duration = end_datetime - start_process
    return {
        "item_id": item_id,
        "start_datetime": start_datetime,
        "end_datetime": end_datetime,
        "repeat_at": repeat_at,
        "process_after": process_after,
        "start_process": start_process,
        "duration": duration,
    }

๐Ÿ—’ ๐Ÿ‘ˆ ๐Ÿ”ข ๐Ÿ”˜ ๐Ÿ”ข โœ”๏ธ ๐Ÿ‘ซ ๐Ÿ  ๐Ÿ’ฝ ๐Ÿ†Ž, & ๐Ÿ‘† ๐Ÿ’ช, ๐Ÿ–ผ, ๐ŸŽญ ๐Ÿ˜ ๐Ÿ“… ๐ŸŽญ, ๐Ÿ’–:

from datetime import datetime, time, timedelta
from typing import Union
from uuid import UUID

from fastapi import Body, FastAPI

app = FastAPI()


@app.put("/items/{item_id}")
async def read_items(
    item_id: UUID,
    start_datetime: Union[datetime, None] = Body(default=None),
    end_datetime: Union[datetime, None] = Body(default=None),
    repeat_at: Union[time, None] = Body(default=None),
    process_after: Union[timedelta, None] = Body(default=None),
):
    start_process = start_datetime + process_after
    duration = end_datetime - start_process
    return {
        "item_id": item_id,
        "start_datetime": start_datetime,
        "end_datetime": end_datetime,
        "repeat_at": repeat_at,
        "process_after": process_after,
        "start_process": start_process,
        "duration": duration,
    }
from datetime import datetime, time, timedelta
from uuid import UUID

from fastapi import Body, FastAPI

app = FastAPI()


@app.put("/items/{item_id}")
async def read_items(
    item_id: UUID,
    start_datetime: datetime | None = Body(default=None),
    end_datetime: datetime | None = Body(default=None),
    repeat_at: time | None = Body(default=None),
    process_after: timedelta | None = Body(default=None),
):
    start_process = start_datetime + process_after
    duration = end_datetime - start_process
    return {
        "item_id": item_id,
        "start_datetime": start_datetime,
        "end_datetime": end_datetime,
        "repeat_at": repeat_at,
        "process_after": process_after,
        "start_process": start_process,
        "duration": duration,
    }