Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 142 for settings (0.2 sec)

  1. docs/em/docs/advanced/settings.md

    ```Python hl_lines="2  5-8  11"
    {!../../../docs_src/settings/tutorial001.py!}
    ```
    
    !!! tip
        🚥 👆 💚 🕳 ⏩ 📁 & 📋, 🚫 ⚙️ 👉 🖼, ⚙️ 🏁 1️⃣ 🔛.
    
    ⤴️, 🕐❔ 👆 ✍ 👐 👈 `Settings` 🎓 (👉 💼, `settings` 🎚), Pydantic 🔜 ✍ 🌐 🔢 💼-😛 🌌,, ↖-💼 🔢 `APP_NAME` 🔜 ✍ 🔢 `app_name`.
    
    ⏭ ⚫️ 🔜 🗜 & ✔ 💽. , 🕐❔ 👆 ⚙️ 👈 `settings` 🎚, 👆 🔜 ✔️ 📊 🆎 👆 📣 (✅ `items_per_user` 🔜 `int`).
    
    ### ⚙️ `settings`
    
    ⤴️ 👆 💪 ⚙️ 🆕 `settings` 🎚 👆 🈸:
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 11.4K bytes
    - Viewed (0)
  2. docs/en/docs/advanced/settings.md

    ### Install `pydantic-settings`
    
    First, install the `pydantic-settings` package:
    
    <div class="termy">
    
    ```console
    $ pip install pydantic-settings
    ---> 100%
    ```
    
    </div>
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 15.7K bytes
    - Viewed (0)
  3. docs/de/docs/advanced/settings.md

    ```Python hl_lines="10"
    {!../../../docs_src/settings/app02/config.py!}
    ```
    
    Beachten Sie, dass wir jetzt keine Standardinstanz `settings = Settings()` erstellen.
    
    ### Die Haupt-Anwendungsdatei
    
    Jetzt erstellen wir eine Abhängigkeit, die ein neues `config.Settings()` zurückgibt.
    
    === "Python 3.9+"
    
        ```Python hl_lines="6  12-13"
        {!> ../../../docs_src/settings/app02_an_py39/main.py!}
        ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:17:14 GMT 2024
    - 17.8K bytes
    - Viewed (0)
  4. docs/zh/docs/advanced/settings.md

    ```Python hl_lines="2  5-8  11"
    {!../../../docs_src/settings/tutorial001.py!}
    ```
    
    !!! tip
        如果您需要一个快速的复制粘贴示例,请不要使用此示例,而应使用下面的最后一个示例。
    
    然后,当您创建该 `Settings` 类的实例(在此示例中是 `settings` 对象)时,Pydantic 将以不区分大小写的方式读取环境变量,因此,大写的变量 `APP_NAME` 仍将为属性 `app_name` 读取。
    
    然后,它将转换和验证数据。因此,当您使用该 `settings` 对象时,您将获得您声明的类型的数据(例如 `items_per_user` 将为 `int` 类型)。
    
    ### 使用 `settings`
    
    然后,您可以在应用程序中使用新的 `settings` 对象:
    
    ```Python hl_lines="18-20"
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 13.9K bytes
    - Viewed (0)
  5. docs/en/docs/how-to/configure-swagger-ui.md

    ## JavaScript-only settings
    
    Swagger UI also allows other configurations to be **JavaScript-only** objects (for example, JavaScript functions).
    
    FastAPI also includes these JavaScript-only `presets` settings:
    
    ```JavaScript
    presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIBundle.SwaggerUIStandalonePreset
    ]
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  6. docs_src/settings/app03_an/main.py

    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,
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 24 20:26:06 GMT 2023
    - 451 bytes
    - Viewed (0)
  7. docs_src/conditional_openapi/tutorial001.py

    from fastapi import FastAPI
    from pydantic_settings import BaseSettings
    
    
    class Settings(BaseSettings):
        openapi_url: str = "/openapi.json"
    
    
    settings = Settings()
    
    app = FastAPI(openapi_url=settings.openapi_url)
    
    
    @app.get("/")
    def root():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 281 bytes
    - Viewed (0)
  8. docs_src/settings/app02/config.py

    from pydantic_settings import BaseSettings
    
    
    class Settings(BaseSettings):
        app_name: str = "Awesome API"
        admin_email: str
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 159 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_settings/test_tutorial001_pv1.py

    from fastapi.testclient import TestClient
    from pytest import MonkeyPatch
    
    from ...utils import needs_pydanticv1
    
    
    @needs_pydanticv1
    def test_settings(monkeypatch: MonkeyPatch):
        monkeypatch.setenv("ADMIN_EMAIL", "******@****.***")
        from docs_src.settings.tutorial001_pv1 import app
    
        client = TestClient(app)
        response = client.get("/info")
        assert response.status_code == 200, response.text
        assert response.json() == {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 556 bytes
    - Viewed (0)
  10. docs_src/settings/app02/main.py

    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,
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 24 20:26:06 GMT 2023
    - 406 bytes
    - Viewed (0)
Back to top