From c59a8a60eb7ceaf3b8f93a9abcd1db639338ecb9 Mon Sep 17 00:00:00 2001 From: Tim Mundt Date: Tue, 5 Sep 2017 09:53:33 +0200 Subject: [PATCH] make the prefix for environment variables alterable --- sanic/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sanic/config.py b/sanic/config.py index 6ffcf7a1..6a53e476 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -195,14 +195,14 @@ class Config(dict): if key.isupper(): self[key] = getattr(obj, key) - def load_environment_vars(self): + def load_environment_vars(self, prefix=SANIC_PREFIX): """ - Looks for any ``SANIC_`` prefixed environment variables and applies + Looks for prefixed environment variables and applies them to the configuration if present. """ for k, v in os.environ.items(): - if k.startswith(SANIC_PREFIX): - _, config_key = k.split(SANIC_PREFIX, 1) + if k.startswith(prefix): + _, config_key = k.split(prefix, 1) try: self[config_key] = int(v) except ValueError: