Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 142 for encoded (0.26 sec)

  1. fastapi/exceptions.py

            ],
            reason: Annotated[
                Union[str, None],
                Doc(
                    """
                    The reason to close the WebSocket connection.
    
                    It is UTF-8-encoded data. The interpretation of the reason is up to the
                    application, it is not specified by the WebSocket specification.
    
                    It could contain text that could be human-readable or interpretable
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 4.9K bytes
    - Viewed (0)
  2. docs_src/handling_errors/tutorial005.py

    from fastapi import FastAPI, Request, status
    from fastapi.encoders import jsonable_encoder
    from fastapi.exceptions import RequestValidationError
    from fastapi.responses import JSONResponse
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    @app.exception_handler(RequestValidationError)
    async def validation_exception_handler(request: Request, exc: RequestValidationError):
        return JSONResponse(
            status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 667 bytes
    - Viewed (0)
  3. docs/en/docs/reference/encoders.md

    # Encoders - `jsonable_encoder`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 71 bytes
    - Viewed (0)
  4. docs/de/docs/reference/encoders.md

    # Encoder – `jsonable_encoder`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Feb 19 15:54:52 GMT 2024
    - 72 bytes
    - Viewed (0)
  5. docs/uk/docs/tutorial/encoder.md

    # JSON Compatible Encoder
    
    Існують випадки, коли вам може знадобитися перетворити тип даних (наприклад, модель Pydantic) в щось сумісне з JSON (наприклад, `dict`, `list`, і т. д.).
    
    Наприклад, якщо вам потрібно зберегти це в базі даних.
    
    Для цього, **FastAPI** надає `jsonable_encoder()` функцію.
    
    ## Використання `jsonable_encoder`
    
    Давайте уявимо, що у вас є база даних `fake_db`, яка приймає лише дані, сумісні з JSON.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 2.6K bytes
    - Viewed (0)
  6. docs/ru/docs/tutorial/encoder.md

    Для этого можно использовать функцию `jsonable_encoder`.
    
    Она принимает объект, например, модель Pydantic, и возвращает его версию, совместимую с JSON:
    
    === "Python 3.10+"
    
        ```Python hl_lines="4  21"
        {!> ../../../docs_src/encoder/tutorial001_py310.py!}
        ```
    
    === "Python 3.6+"
    
        ```Python hl_lines="5  22"
        {!> ../../../docs_src/encoder/tutorial001.py!}
        ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 23 13:56:12 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  7. docs/zh/docs/advanced/response-directly.md

    # 直接返回响应
    
    当你创建一个 **FastAPI** *路径操作* 时,你可以正常返回以下任意一种数据:`dict`,`list`,Pydantic 模型,数据库模型等等。
    
    **FastAPI** 默认会使用 `jsonable_encoder` 将这些类型的返回值转换成 JSON 格式,`jsonable_encoder` 在 [JSON 兼容编码器](../tutorial/encoder.md){.internal-link target=_blank} 中有阐述。
    
    然后,**FastAPI** 会在后台将这些兼容 JSON 的数据(比如字典)放到一个 `JSONResponse` 中,该 `JSONResponse` 会用来发送响应给客户端。
    
    但是你可以在你的 *路径操作* 中直接返回一个 `JSONResponse`。
    
    直接返回响应可能会有用处,比如返回自定义的响应头和 cookies。
    
    ## 返回 `Response`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 12 00:06:16 GMT 2022
    - 3.1K bytes
    - Viewed (0)
  8. docs/es/docs/advanced/response-directly.md

    Por defecto, **FastAPI** convertiría automáticamente ese valor devuelto a JSON usando el `jsonable_encoder` explicado en [Codificador Compatible JSON](../tutorial/encoder.md){.internal-link target=_blank}.
    
    Luego, tras bastidores, pondría esos datos compatibles con JSON (por ejemplo, un `dict`) dentro de una `JSONResponse` que se usaría para enviar la respuesta al cliente.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Jan 13 11:57:27 GMT 2024
    - 3.2K bytes
    - Viewed (0)
  9. docs/ja/docs/advanced/response-directly.md

    # レスポンスを直接返す
    
    **FastAPI** の *path operation* では、通常は任意のデータを返すことができます: 例えば、 `dict`、`list`、Pydanticモデル、データベースモデルなどです。
    
    デフォルトでは、**FastAPI** は [JSON互換エンコーダ](../tutorial/encoder.md){.internal-link target=_blank} で説明されている `jsonable_encoder` により、返す値を自動的にJSONに変換します。
    
    このとき背後では、JSON互換なデータ (例えば`dict`) を、クライアントへ送信されるレスポンスとして利用される `JSONResponse` の中に含めます。
    
    しかし、*path operation* から `JSONResponse` を直接返すこともできます。
    
    これは例えば、カスタムヘッダーやcookieを返すときに便利です。
    
    ## `Response` を返す
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Nov 05 22:50:38 GMT 2020
    - 3.6K bytes
    - Viewed (0)
  10. docs_src/security/tutorial007_an.py

    ):
        current_username_bytes = credentials.username.encode("utf8")
        correct_username_bytes = b"stanleyjobson"
        is_correct_username = secrets.compare_digest(
            current_username_bytes, correct_username_bytes
        )
        current_password_bytes = credentials.password.encode("utf8")
        correct_password_bytes = b"swordfish"
        is_correct_password = secrets.compare_digest(
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 1.2K bytes
    - Viewed (0)
Back to top