From 9e435787c6674f743c69490dcc8f3ac8595dacac Mon Sep 17 00:00:00 2001 From: Egg <45681670+Radical-Egg@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:40:39 -0700 Subject: [PATCH] Environment variables for default port and bind address (#342) * Add env vars to override default bind address and port * Update main.py Prefix bind address and port with SNAPPASS_ * Update README.rst update readme to prefix SNAPPASS_ to bind address and port --------- Co-authored-by: Yuru Shao --- README.rst | 4 ++++ snappass/main.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6e98da7..b816cea 100644 --- a/README.rst +++ b/README.rst @@ -96,6 +96,10 @@ need to change this. ``HOST_OVERRIDE``: (optional) Used to override the base URL if the app is unaware. Useful when running behind reverse proxies like an identity-aware SSO. Example: ``sub.domain.com`` +``SNAPPASS_BIND_ADDRESS``: (optional) Used to override the default bind address of 0.0.0.0 for flask app Example: ``127.0.0.1`` + +``SNAPPASS_PORT``: (optional) Used to override the default port of 5000 Example: ``6000`` + APIs ---- diff --git a/snappass/main.py b/snappass/main.py index 6f06572..2c16cdc 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -353,7 +353,8 @@ def health_check(): @check_redis_alive def main(): - app.run(host='0.0.0.0') + app.run(host=os.environ.get('SNAPPASS_BIND_ADDRESS', '0.0.0.0'), + port=os.environ.get('SNAPPASS_PORT', 5000)) if __name__ == '__main__':