โ ๐ฝ ๐¶
๐ ๐, ๐ โ๏ธ โ๏ธ โ ๐ ๐, ๐:
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,
}