From a9f4bf18af4ecd2a32baefc5b7bdd277988933d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Garc=C3=ADa=20Amor?= Date: Sat, 12 Mar 2016 13:45:45 +0100 Subject: [PATCH 1/2] Added support to configure listen host and port --- bin/srv.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/srv.py b/bin/srv.py index 809b3a5..f19625f 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -25,6 +25,8 @@ app = Flask(__name__) MYDIR = os.environ.get('WTTR_MYDIR', os.path.abspath(os.path.dirname( os.path.dirname('__file__') ))) GEOLITE = os.environ.get('WTTR_GEOLITE', os.path.join( MYDIR, "GeoLite2-City.mmdb" )) WEGO = os.environ.get('WTTR_WEGO', "/home/igor/go/bin/wego") +LISTEN_HOST = os.environ.get('WTTR_LISTEN_HOST', "127.0.0.1") +LISTEN_PORT = int(os.environ.get('WTTR_LISTEN_PORT', "8002")) CACHEDIR = os.path.join( MYDIR, "cache" ) IP2LCACHE = os.path.join( MYDIR, "cache/ip2l" ) @@ -260,6 +262,6 @@ def wttr(location = None): logging.error("Exception has occured", exc_info=1) return str(e).rstrip()+"\n" -server = WSGIServer(("", 8002), app) +server = WSGIServer((LISTEN_HOST, LISTEN_PORT), app) server.serve_forever() From 9e0a9a5d3917c283e4f46c2f87cd9d03d720a458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Garc=C3=ADa=20Amor?= Date: Wed, 8 Jun 2016 17:02:28 +0200 Subject: [PATCH 2/2] Fixed unicode decode error --- bin/srv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index f19625f..85b6a12 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -111,8 +111,8 @@ def error( text ): raise RuntimeError(text) def log( text ): - print text - logging.info( text ) + print text.encode('utf-8') + logging.info( text.encode('utf-8') ) def is_ip( ip ): if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip) is None: