Search Options

Results per page
Sort
Preferred Languages
Advance

Results 31 - 40 of 266 for Cookies (0.1 sec)

  1. docs_src/cookie_param_models/tutorial002_pv1_py310.py

    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        class Config:
            extra = "forbid"
    
        session_id: str
        fatebook_tracker: str | None = None
        googall_tracker: str | None = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Cookies = Cookie()):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 347 bytes
    - Viewed (0)
  2. docs_src/cookie_param_models/tutorial001_an_py310.py

    from typing import Annotated
    
    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        session_id: str
        fatebook_tracker: str | None = None
        googall_tracker: str | None = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 343 bytes
    - Viewed (0)
  3. docs_src/cookie_param_models/tutorial001_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        session_id: str
        fatebook_tracker: Union[str, None] = None
        googall_tracker: Union[str, None] = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 362 bytes
    - Viewed (0)
  4. docs/pt/docs/advanced/response-headers.md

    **FastAPI** usará essa resposta *temporária* para extrair os cabeçalhos (cookies e código de status também) e os colocará na resposta final que contém o valor que você retornou, filtrado por qualquer `response_model`.
    
    Você também pode declarar o parâmetro `Response` em dependências e definir cabeçalhos (e cookies) nelas.
    
    ## Retornar uma `Response` diretamente
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 16 07:44:45 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  5. docs/zh/docs/advanced/response-headers.md

    你可以在你的*路径操作函数*中声明一个`Response`类型的参数(就像你可以为cookies做的那样)。
    
    然后你可以在这个*临时*响应对象中设置头部。
    ```Python hl_lines="1  7-8"
    {!../../docs_src/response_headers/tutorial002.py!}
    ```
    
    然后你可以像平常一样返回任何你需要的对象(例如一个`dict`或者一个数据库模型)。如果你声明了一个`response_model`,它仍然会被用来过滤和转换你返回的对象。
    
    **FastAPI**将使用这个临时响应来提取头部(也包括cookies和状态码),并将它们放入包含你返回的值的最终响应中,该响应由任何`response_model`过滤。
    
    你也可以在依赖项中声明`Response`参数,并在其中设置头部(和cookies)。
    
    ## 直接返回 `Response`
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2K bytes
    - Viewed (0)
  6. docs/es/docs/tutorial/cookie-params.md

    # Parámetros de Cookie
    
    Puedes definir parámetros de Cookie de la misma manera que defines parámetros de `Query` y `Path`.
    
    ## Importar `Cookie`
    
    Primero importa `Cookie`:
    
    {* ../../docs_src/cookie_params/tutorial001_an_py310.py hl[3]*}
    
    ## Declarar parámetros de `Cookie`
    
    Luego declara los parámetros de cookie usando la misma estructura que con `Path` y `Query`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Oct 28 10:33:43 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  7. docs_src/cookie_param_models/tutorial002_pv1_an_py310.py

    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        class Config:
            extra = "forbid"
    
        session_id: str
        fatebook_tracker: str | None = None
        googall_tracker: str | None = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 387 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_cookie_param_models/test_tutorial001.py

        client = TestClient(mod.app)
        return client
    
    
    def test_cookie_param_model(client: TestClient):
        with client as c:
            c.cookies.set("session_id", "123")
            c.cookies.set("fatebook_tracker", "456")
            c.cookies.set("googall_tracker", "789")
            response = c.get("/items/")
        assert response.status_code == 200
        assert response.json() == {
            "session_id": "123",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 7.4K bytes
    - Viewed (0)
  9. docs/uk/docs/tutorial/cookie-params.md

    ```
    
    ////
    
    /// note | "Технічні Деталі"
    
    `Cookie` це "сестра" класів `Path` і `Query`. Вони наслідуються від одного батьківського класу `Param`.
    Але пам'ятайте, що коли ви імпортуєте `Query`, `Path`, `Cookie` та інше з `fastapi`, це фактично функції, що повертають спеціальні класи.
    
    ///
    
    /// info
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.1K bytes
    - Viewed (0)
  10. docs/en/docs/tutorial/cookie-params.md

    ```
    
    ////
    
    /// note | "Technical Details"
    
    `Cookie` is a "sister" class of `Path` and `Query`. It also inherits from the same common `Param` class.
    
    But remember that when you import `Query`, `Path`, `Cookie` and others from `fastapi`, those are actually functions that return special classes.
    
    ///
    
    /// info
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.3K bytes
    - Viewed (0)
Back to top