Skip to content

Commit eefced1

Browse files
committed
Refactored config logic
1 parent 7bdbef8 commit eefced1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packet/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
app = Flask(__name__)
1717

1818
# Load default configuration and any environment variable overrides
19-
app.config.from_pyfile(os.path.join(os.getcwd(), "config.env.py"))
19+
_root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
20+
app.config.from_pyfile(os.path.join(_root_dir, "config.env.py"))
2021

2122
# Load file based configuration overrides if present
22-
if os.path.exists(os.path.join(os.getcwd(), "config.py")):
23-
app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
23+
_pyfile_config = os.path.join(_root_dir, "config.py")
24+
if os.path.exists(_pyfile_config):
25+
app.config.from_pyfile(_pyfile_config)
2426

2527
app.config["VERSION"] = __version__
2628

0 commit comments

Comments
 (0)