Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 44 for _get_settings (0.13 sec)

  1. docs_src/settings/app02/main.py

    from functools import lru_cache
    
    from fastapi import Depends, FastAPI
    
    from .config import Settings
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return Settings()
    
    
    @app.get("/info")
    async def info(settings: Settings = Depends(get_settings)):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 406 bytes
    - Viewed (0)
  2. docs_src/settings/app02_an_py39/main.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    
    from .config import Settings
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return Settings()
    
    
    @app.get("/info")
    async def info(settings: Annotated[Settings, Depends(get_settings)]):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 445 bytes
    - Viewed (0)
  3. docs_src/settings/app03_an_py39/main.py

    from fastapi import Depends, FastAPI
    from typing_extensions import Annotated
    
    from . import config
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return config.Settings()
    
    
    @app.get("/info")
    async def info(settings: Annotated[config.Settings, Depends(get_settings)]):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 462 bytes
    - Viewed (0)
  4. docs_src/settings/app03/main.py

    from functools import lru_cache
    
    from fastapi import Depends, FastAPI
    
    from . import config
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return config.Settings()
    
    
    @app.get("/info")
    async def info(settings: config.Settings = Depends(get_settings)):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 412 bytes
    - Viewed (0)
  5. docs_src/settings/app02_an/main.py

    from fastapi import Depends, FastAPI
    from typing_extensions import Annotated
    
    from .config import Settings
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return Settings()
    
    
    @app.get("/info")
    async def info(settings: Annotated[Settings, Depends(get_settings)]):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 456 bytes
    - Viewed (0)
  6. docs_src/settings/app03_an/main.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    
    from . import config
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return config.Settings()
    
    
    @app.get("/info")
    async def info(settings: Annotated[config.Settings, Depends(get_settings)]):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
            "items_per_user": settings.items_per_user,
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 451 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_settings/test_app02.py

    
    @needs_pydanticv2
    def test_settings(monkeypatch: MonkeyPatch):
        from docs_src.settings.app02 import main
    
        monkeypatch.setenv("ADMIN_EMAIL", "******@****.***")
        settings = main.get_settings()
        assert settings.app_name == "Awesome API"
        assert settings.items_per_user == 50
    
    
    @needs_pydanticv2
    def test_override_settings():
        from docs_src.settings.app02 import test_main
    
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 488 bytes
    - Viewed (0)
  8. docs/em/docs/advanced/settings.md

    ๐Ÿšฅ ๐Ÿ”— ๐Ÿ”ข ๐Ÿ’–:
    
    ```Python
    def get_settings():
        return Settings()
    ```
    
    ๐Ÿ‘ฅ ๐Ÿ”œ โœ ๐Ÿ‘ˆ ๐ŸŽš ๐Ÿ”  ๐Ÿ“จ, & ๐Ÿ‘ฅ ๐Ÿ”œ ๐Ÿ‘‚ `.env` ๐Ÿ“ ๐Ÿ”  ๐Ÿ“จ. ๐Ÿ‘ถ ๐Ÿ‘ถ
    
    โœ‹๏ธ ๐Ÿ‘ฅ โš™๏ธ `@lru_cache` ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ”› ๐Ÿ”, `Settings` ๐ŸŽš ๐Ÿ”œ โœ ๐Ÿ•ด ๐Ÿ•, ๐Ÿฅ‡ ๐Ÿ•ฐ โšซ๏ธ ๐Ÿค™. ๐Ÿ‘ถ ๐Ÿ‘ถ
    
    ```Python hl_lines="1  10"
    {!../../../docs_src/settings/app03/main.py!}
    ```
    
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Fri Mar 22 01:42:11 UTC 2024
    - 11.4K bytes
    - Viewed (0)
  9. docs/en/docs/advanced/settings.md

        ```Python hl_lines="1  10"
        {!> ../../../docs_src/settings/app03/main.py!}
        ```
    
    Then for any subsequent calls of `get_settings()` in the dependencies for the next requests, instead of executing the internal code of `get_settings()` and creating a new `Settings` object, it will return the same object that was returned on the first call, again and again.
    
    #### `lru_cache` Technical Details
    
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Sat May 18 23:43:13 UTC 2024
    - 15.7K bytes
    - Viewed (0)
  10. docs/de/docs/advanced/settings.md

        ```Python hl_lines="1  10"
        {!> ../../../docs_src/settings/app03/main.py!}
        ```
    
    Dann wird bei allen nachfolgenden Aufrufen von `get_settings()`, in den Abhรคngigkeiten fรผr darauffolgende Requests, dasselbe Objekt zurรผckgegeben, das beim ersten Aufruf zurรผckgegeben wurde, anstatt den Code von `get_settings()` erneut auszufรผhren und ein neues `Settings`-Objekt zu erstellen.
    
    #### Technische Details zu `lru_cache`
    
    Registered: Mon Jun 17 08:32:26 UTC 2024
    - Last Modified: Sat Mar 30 20:17:14 UTC 2024
    - 17.8K bytes
    - Viewed (0)
Back to top