30 lines
915 B
Python
30 lines
915 B
Python
import os
|
|
|
|
def load_config(mode=os.environ.get('MODE')):
|
|
"""
|
|
Load application configuration from environment variables.
|
|
The MODE environment variable determines which default CORS origins to use,
|
|
but all secrets are loaded from environment variables.
|
|
"""
|
|
from settings import ApplicationConfig
|
|
|
|
print(f"Mode is {mode or 'not set (defaulting to DEVELOPMENT)'}")
|
|
|
|
# Validate required configuration
|
|
try:
|
|
ApplicationConfig.validate_required()
|
|
except ValueError as e:
|
|
print(f"\033[91mConfiguration Error: {e}\033[0m")
|
|
raise
|
|
|
|
# Print appropriate warning based on database
|
|
if ApplicationConfig.POSTGRES_DBNAME00 == 'eamco':
|
|
print("\033[92mTest database confirmed\033[0m")
|
|
else:
|
|
print("\033[91mPRODUCTION DATABASE\033[0m")
|
|
|
|
if mode == 'PRODUCTION':
|
|
print("\033[91mPRODUCTION MODE\033[0m")
|
|
|
|
return ApplicationConfig
|