File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/mrmat_python_api_fastapi Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,18 @@ class Config:
3030 A class to deal with application configuration
3131 """
3232 secret_key : str = secrets .token_urlsafe (16 )
33- db_url : str = 'sqlite://'
33+ db_url : str = 'sqlite:/// '
3434
3535 @staticmethod
36- def from_json_file (file : str | None = os .getenv ('APP_CONFIG' )):
36+ def from_context (file : str | None = os .getenv ('APP_CONFIG' )):
3737 runtime_config = Config ()
3838 if file and os .path .exists (file ):
3939 with open (file , 'r' , encoding = 'UTF-8' ) as c :
4040 file_config = json .load (c )
41- runtime_config .secret_key = file_config .get_owner ('secret_key' , secrets .token_urlsafe (16 ))
42- runtime_config .db_url = file_config .get_owner ('db_url' , 'sqlite://' )
41+ runtime_config .secret_key = file_config .get ('secret_key' , secrets .token_urlsafe (16 ))
42+ runtime_config .db_url = file_config .get ('db_url' , 'sqlite:///' )
43+ if 'APP_CONFIG_SECRET_KEY' in os .environ :
44+ runtime_config .secret_key = os .getenv ('APP_CONFIG_SECRET_KEY' , secrets .token_urlsafe (16 ))
45+ if 'APP_CONFIG_DB_URL' in os .environ :
46+ runtime_config .db_url = os .getenv ('APP_CONFIG_DB_URL' , '' )
4347 return runtime_config
You can’t perform that action at this time.
0 commit comments