Skip to content

Commit

Permalink
Merge pull request #110 from redjax/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
redjax authored Jan 8, 2025
2 parents b3e6027 + 00bdefb commit 6af2b97
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/programming/python/dynaconf/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Here you can see a simple example of configuring an app with Dynaconf. The app w

I am using [HTTPX](https://www.python-httpx.org/) as my request client because I prefer it over the `requests` package.

For the sake of example, this example will use Dynaconf's environments feature to separate configurations by domain; this example does not use `[dev]`/`[production]`/etc environments. If you want to use these environments instead, create separate files for each `[section]` you see below.
For the sake of example, this app will use Dynaconf's environments feature to separate configurations by domain; this example does not use `[dev]`/`[production]`/etc environments. If you want to use these environments instead, create separate files for each `[section]` you see below.

### Settings files

Expand Down Expand Up @@ -274,7 +274,7 @@ The FakerAPI does not require an API key, but if it did, I would also declare it
[default]
fakerapi_api_key = ""

[dev]
[prod]
## Put a placeholder API key for the user to replace when they create a
# .secrets.local.toml file
fakerapi_api_key = "<your-fakerapi-api-key>"
Expand Down Expand Up @@ -311,17 +311,17 @@ I am keeping things simple for this example by creating a `settings.py` file, wh
from dynaconf import Dynaconf

## Initialize a logging config object.
# This object will only load variables in the [logging] section of settings.toml/.secrets.toml,
# or from environment variables that start with DYNACONF_LOG_ or LOG_
# This object will only load variables beginning with DYNACONF_LOG_ or LOG_ from
# the settings.toml/.secrets.toml file, and the [env] matching your ENV_FOR_DYNACONF value
LOGGING_SETTINGS = Dynaconf(
environments=True,
envvar_prefix="LOG",
settings_files=["settings.toml", ".secrets.toml"]
)

## Initialize FakerAPI config object.
# This object will only load variables in the [fakerapi] section of settings.toml/.secrets.toml,
# or from environment variables that start with DYNACONF_FAKERAPI_ or FAKERAPI_
# This object will only load variables beginning with DYNACONF_FAKERAPI_ or FAKERAPI_ from
# the settings.toml/.secrets.toml file, and the [env] matching your ENV_FOR_DYNACONF value
FAKERAPI_SETTINGS = Dynaconf(
environments=True,
envvar_prefix="FAKERAPI",
Expand Down Expand Up @@ -351,7 +351,7 @@ if __name__ == "__main__":
# Note that I'm omitting 'default=' from the .get(). This means if the
# value isn't found in the environment or TOML settings files, the value
# will be None.
url: str = f"{FAKERAPI_SETTINGS.get('FAKERAPI_BASE_URL')}/{FAKERAPI_SETTINGS.get('FAKERAPI_ENDPOINT')}"
url: str = f"{FAKERAPI_SETTINGS.get('FAKERAPI_BASE_URL')}/{FAKERAPI_SETTINGS.get('FAKERAPI_ENDPOINT')}?_quantity={FAKERAPI_SETTINGS.get('FAKERAPI_QUANTITY')}"
params = {"_quantity": FAKERAPI_SETTINGS.get("FAKERAPI_QUANTITY")}

req = httpx.Request(method="GET", url=url, params=params)
Expand Down

0 comments on commit 6af2b97

Please sign in to comment.