From d3f21f7ec0bd3b1532adee1bc15af7cd3bc2b037 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Fri, 11 Jan 2019 00:31:37 +0530 Subject: [PATCH] Add /plain endpoints for windows --- server.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/server.py b/server.py index 3826ec7..0a79f7c 100644 --- a/server.py +++ b/server.py @@ -162,6 +162,10 @@ def main(location, geocoder, cache_db, kind, unit): "https://darksky.net/poweredby/\n") +def strip_colors(text): + return re.sub('\033\\[[0-9;]+?m', '', text) + + app.add_url_rule('/', 'location', lambda location: main(location, geocoder, cache_db, "daily", "c")) @@ -179,3 +183,27 @@ app.add_url_rule('/f//', 'location_f/', lambda location: app.add_url_rule('/f//t', 'today_location_f', lambda location: main(location, geocoder, cache_db, "hourly", "f")) + +app.add_url_rule('/plain/', 'plain_location', lambda location: + strip_colors(main(location, geocoder, cache_db, "daily", + "c"))) + +app.add_url_rule('/plain//', 'plain_location/', lambda location: + strip_colors(main(location, geocoder, cache_db, "daily", + "c"))) + +app.add_url_rule('/plain//t', 'plain_today_location', lambda + location: strip_colors(main(location, geocoder, cache_db, + "hourly", "c"))) + +app.add_url_rule('/plain/f/', 'plain_location_f', lambda location: + strip_colors(main(location, geocoder, cache_db, "daily", + "f"))) + +app.add_url_rule('/plain/f//', 'plain_location_f/', lambda location: + strip_colors(main(location, geocoder, cache_db, "daily", + "f"))) + +app.add_url_rule('/plain/f//t', 'plain_today_location_f', lambda + location: strip_colors(main(location, geocoder, cache_db, + "hourly", "f")))