-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
28 lines (24 loc) · 987 Bytes
/
config.py
File metadata and controls
28 lines (24 loc) · 987 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
import os
from functools import lru_cache
class Settings:
"""Production settings class"""
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@db/")
DATABASE_NAME = os.getenv("DATABASE_NAME", "example_prod")
SECRET_KEY = os.getenv("SECRET_KEY", "secret_key")
class DevSettings(Settings):
"""Development settings class"""
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@db/")
DATABASE_NAME = os.getenv("DATABASE_NAME", "example_dev")
class TestSettings(Settings):
"""Test settings class"""
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@db/")
DATABASE_NAME = os.getenv("DATABASE_NAME", "example_test")
@lru_cache
def get_settings():
"""Return settings based on ENV variable"""
env = os.getenv("ENV", "dev")
if env == "test":
return TestSettings()
if env == "dev":
return DevSettings()
return Settings() # Default to production settings