Skip to content

Commit

Permalink
Set default value for hostname
Browse files Browse the repository at this point in the history
This will avoid raising KeyError exceptions when trying to fetch the
value of the HOSTNAME env variable on faasd.

Signed-off-by: Mehdi Yedes <mehdi.yedes@gmail.com>
  • Loading branch information
mehyedes authored and alexellis committed Mar 30, 2020
1 parent f805dad commit e2e2e9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions template/python3-http-armhf/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):

class Context:
def __init__(self):
self.hostname = os.environ['HOSTNAME']
self.hostname = os.getenv('HOSTNAME', 'localhost')

def format_status_code(resp):
if 'statusCode' in resp:
Expand Down Expand Up @@ -66,4 +66,4 @@ def call_handler(path):
return resp

if __name__ == '__main__':
serve(app, host='0.0.0.0', port=5000)
serve(app, host='0.0.0.0', port=5000)
4 changes: 2 additions & 2 deletions template/python3-http/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):

class Context:
def __init__(self):
self.hostname = os.environ['HOSTNAME']
self.hostname = os.getenv('HOSTNAME', 'localhost')

def format_status_code(resp):
if 'statusCode' in resp:
Expand Down Expand Up @@ -66,4 +66,4 @@ def call_handler(path):
return resp

if __name__ == '__main__':
serve(app, host='0.0.0.0', port=5000)
serve(app, host='0.0.0.0', port=5000)

0 comments on commit e2e2e9e

Please sign in to comment.