From 32c1686878e1a4c0edf272728286271378494ba6 Mon Sep 17 00:00:00 2001 From: Santiago Basulto Date: Tue, 21 Feb 2017 20:16:07 -0300 Subject: [PATCH] Remove PLAIN_TEXT_AGENTS from globals scope and add python-requests --- bin/srv.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index 1abd000..1149819 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -40,6 +40,13 @@ We were unable to find your location, so we have brought you to Oymyakon, one of the coldest permanently inhabited locales on the planet. """ +PLAIN_TEXT_AGENTS = [ + "curl", + "httpie", + "lwp-request", + "wget", + "python-requests" +] if not os.path.exists(os.path.dirname( LOG_FILE )): os.makedirs( os.path.dirname( LOG_FILE ) ) @@ -218,16 +225,10 @@ def send_favicon(): @app.route("/") @app.route("/") def wttr(location = None): - plain_text_agents = [ - "curl", - "httpie", - "lwp-request", - "wget", - ] user_agent = request.headers.get('User-Agent').lower() - if any(agent in user_agent for agent in plain_text_agents): + if any(agent in user_agent for agent in PLAIN_TEXT_AGENTS): html_output = False else: html_output = True