forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
33 lines (25 loc) · 793 Bytes
/
config.py
File metadata and controls
33 lines (25 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""app.config.py"""
import functools
import logging
from pydantic import AnyUrl, BaseSettings
CFG_LOGGER = logging.getLogger("app.config")
class _Settings(BaseSettings):
port: int = 5000
rediscloud_url: AnyUrl = None
local_redis_url: AnyUrl = None
# Scout APM
scout_name: str = None
# Sentry
sentry_dsn: str = None
@functools.lru_cache()
def get_settings(**kwargs) -> BaseSettings:
"""
Read settings from the environment or `.env` file.
https://pydantic-docs.helpmanual.io/usage/settings/#dotenv-env-support
Usage:
import app.config
settings = app.config.get_settings(_env_file="")
port_number = settings.port
"""
CFG_LOGGER.info("Loading Config settings from Environment ...")
return _Settings(**kwargs)