77load_env ()
88APP_TITLE = ":blue[Greeting Feature]"
99DEFAULT_GREETING = "Hello"
10+ DEFAULT_PORT = 8501
1011FAQ_TITLE = "FAQs"
1112
1213logging .basicConfig (
2223COMPANY_LOGO = ASSETS_DIR / "logo.png"
2324
2425
25- def safe_get (secret_path : str , env_key : str = "" , default : str = "" ) -> str :
26+ def safe_get (env_key : str = "" , default : str = "" ) -> str :
2627 """
2728 Safely retrieve a configuration value from:
2829 1. Streamlit secrets (if secrets.toml exists)
@@ -42,21 +43,25 @@ def safe_get(secret_path: str, env_key: str = "", default: str = "") -> str:
4243 source = "env"
4344
4445 logging .info (
45- f"Loaded config for '{ env_key or secret_path } ' from [{ source } ]" ,
46+ f"Loaded config for '{ env_key } ' from [{ source } ]" ,
4647 extra = {"color" : "yellow" },
4748 )
4849 return value
4950
5051
5152def get_mongo_config ():
5253 return {
53- "MONGODB_URI" : safe_get ("mongodb.MONGODB_URI" , " MONGODB_URI" ),
54- "DATABASE_NAME" : safe_get ("mongodb.DATABASE_NAME" , " DATABASE_NAME" ),
54+ "MONGODB_URI" : safe_get ("MONGODB_URI" ),
55+ "DATABASE_NAME" : safe_get ("DATABASE_NAME" ),
5556 }
5657
5758
59+ PORT = safe_get ("PORT" , DEFAULT_PORT )
60+ PORT_API = safe_get ("API_PORT" , int (PORT ) + 1 )
61+
62+
5863MONGO_CONFIG = get_mongo_config ()
5964# === Environment Selection ===
60- ENVIRONMENT = safe_get ("env.ENVIRONMENT" , " ENVIRONMENT" , "development" ).lower ()
65+ ENVIRONMENT = safe_get ("ENVIRONMENT" , "development" ).lower ()
6166logging .info (f"Environment: { ENVIRONMENT } " , extra = {"color" : "yellow" })
6267logging .info (f"Project root: { PROJECT_ROOT } " , extra = {"color" : "yellow" })
0 commit comments