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 <yshao@pinterest.com>
This commit is contained in:
Egg 2024-08-02 15:40:39 -07:00 committed by GitHub
parent 4e5fc2ef1f
commit 9e435787c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -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`` ``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 APIs
---- ----

View file

@ -353,7 +353,8 @@ def health_check():
@check_redis_alive @check_redis_alive
def main(): 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__': if __name__ == '__main__':