- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 98 for datetime (0.05 seconds)
-
tests/test_jsonable_encoder.py
import warnings from collections import deque from dataclasses import dataclass from datetime import datetime, timezone from decimal import Decimal from enum import Enum from math import isinf, isnan from pathlib import PurePath, PurePosixPath, PureWindowsPath from typing import TypedDict import pytest from fastapi._compat import Undefined from fastapi.encoders import jsonable_encoder from fastapi.exceptions import PydanticV1NotSupportedError
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 9.2K bytes - Click Count (0) -
docs_src/openapi_webhooks/tutorial001_py310.py
from datetime import datetime from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Subscription(BaseModel): username: str monthly_fee: float start_date: datetime @app.webhooks.post("new-subscription") def new_subscription(body: Subscription): """ When a new user subscribes to your service we'll send you a POST request with this
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 550 bytes - Click Count (0) -
docs/ko/docs/tutorial/encoder.md
이를 위해, **FastAPI**에서는 `jsonable_encoder()` 함수를 제공합니다. ## `jsonable_encoder` 사용 { #using-the-jsonable-encoder } JSON 호환 가능 데이터만 수신하는 `fake_db` 데이터베이스가 존재한다고 가정하겠습니다. 예를 들면, `datetime` 객체는 JSON과 호환되지 않으므로 이 데이터베이스는 이를 받지 않습니다. 따라서 `datetime` 객체는 [ISO 형식](https://en.wikipedia.org/wiki/ISO_8601)의 데이터를 포함하는 `str`로 변환되어야 합니다. 같은 방식으로 이 데이터베이스는 Pydantic 모델(속성이 있는 객체)을 받지 않고, `dict`만을 받습니다. 이를 위해 `jsonable_encoder`를 사용할 수 있습니다.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:06:26 GMT 2026 - 1.8K bytes - Click Count (0) -
docs/en/docs/tutorial/encoder.md
## Using the `jsonable_encoder` { #using-the-jsonable-encoder } Let's imagine that you have a database `fake_db` that only receives JSON compatible data. For example, it doesn't receive `datetime` objects, as those are not compatible with JSON. So, a `datetime` object would have to be converted to a `str` containing the data in [ISO format](https://en.wikipedia.org/wiki/ISO_8601).Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 1.6K bytes - Click Count (0) -
docs/zh-hant/docs/tutorial/encoder.md
想像你有一個只接受與 JSON 相容資料的資料庫 `fake_db`。 例如,它不接受 `datetime` 物件,因為那與 JSON 不相容。 因此,必須將 `datetime` 物件轉為一個以 [ISO 格式](https://en.wikipedia.org/wiki/ISO_8601) 表示資料的 `str`。 同樣地,這個資料庫不會接受 Pydantic 模型(帶有屬性的物件),只接受 `dict`。 你可以使用 `jsonable_encoder` 來處理。 它接收一個物件(例如 Pydantic 模型),並回傳一個與 JSON 相容的版本: {* ../../docs_src/encoder/tutorial001_py310.py hl[4,21] *} 在此範例中,它會把 Pydantic 模型轉成 `dict`,並將 `datetime` 轉成 `str`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 1.5K bytes - Click Count (0) -
docs/zh/docs/tutorial/encoder.md
让我们假设你有一个数据库名为`fake_db`,它只能接收与JSON兼容的数据。 例如,它不接收`datetime`这类的对象,因为这些对象与JSON不兼容。 因此,`datetime`对象必须转换为包含[ISO 格式](https://en.wikipedia.org/wiki/ISO_8601)的`str`类型对象。 同样,这个数据库也不会接收Pydantic模型(带有属性的对象),而只接收`dict`。 对此你可以使用`jsonable_encoder`。 它接收一个对象,比如Pydantic模型,并会返回一个JSON兼容的版本: {* ../../docs_src/encoder/tutorial001_py310.py hl[4,21] *} 在这个例子中,它将Pydantic模型转换为`dict`,并将`datetime`转换为`str`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 1.5K bytes - Click Count (0) -
docs/ja/docs/tutorial/encoder.md
例えば、データベースに保存する必要がある場合です。 そのために、**FastAPI** は`jsonable_encoder()`関数を提供しています。 ## `jsonable_encoder`の使用 { #using-the-jsonable-encoder } JSON互換のデータのみを受信するデータベース`fake_db`があるとしましょう。 例えば、`datetime`オブジェクトはJSONと互換性がないので、受け取られません。 そのため、`datetime`オブジェクトは[ISO形式](https://en.wikipedia.org/wiki/ISO_8601)のデータを含む`str`に変換されなければなりません。 同様に、このデータベースはPydanticモデル(属性を持つオブジェクト)を受け取らず、`dict`だけを受け取ります。 そのために`jsonable_encoder`を使用することができます。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 1.8K bytes - Click Count (0) -
scripts/people.py
self.last_query_cost: int = 1 self.remaining_points: int = 5000 self.reset_at: datetime = datetime.fromtimestamp(0, timezone.utc) self.last_request_start_time: datetime = datetime.fromtimestamp(0, timezone.utc) self.speed_multiplier: float = 1.0 def __enter__(self) -> "RateLimiter": now = datetime.now(tz=timezone.utc) # Handle primary rate limits primary_limit_wait_time = 0.0Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Mar 23 13:51:24 GMT 2026 - 15K bytes - Click Count (0) -
docs_src/security/tutorial004_py310.py
from datetime import datetime, timedelta, timezone import jwt from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from jwt.exceptions import InvalidTokenError from pwdlib import PasswordHash from pydantic import BaseModel # to get a string like this run: # openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 4.1K bytes - Click Count (0) -
docs_src/security/tutorial005_py310.py
from datetime import datetime, timedelta, timezone import jwt from fastapi import Depends, FastAPI, HTTPException, Security, status from fastapi.security import ( OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, ) from jwt.exceptions import InvalidTokenError from pwdlib import PasswordHash from pydantic import BaseModel, ValidationError # to get a string like this run: # openssl rand -hex 32
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 5.3K bytes - Click Count (0)