Add /plain endpoints for windows

This commit is contained in:
Ceda EI 2019-01-11 00:31:37 +05:30
parent 63213d43df
commit d3f21f7ec0
1 changed files with 28 additions and 0 deletions

View File

@ -162,6 +162,10 @@ def main(location, geocoder, cache_db, kind, unit):
"https://darksky.net/poweredby/\n") "https://darksky.net/poweredby/\n")
def strip_colors(text):
return re.sub('\033\\[[0-9;]+?m', '', text)
app.add_url_rule('/<location>', 'location', lambda location: app.add_url_rule('/<location>', 'location', lambda location:
main(location, geocoder, cache_db, "daily", "c")) main(location, geocoder, cache_db, "daily", "c"))
@ -179,3 +183,27 @@ app.add_url_rule('/f/<location>/', 'location_f/', lambda location:
app.add_url_rule('/f/<location>/t', 'today_location_f', lambda location: app.add_url_rule('/f/<location>/t', 'today_location_f', lambda location:
main(location, geocoder, cache_db, "hourly", "f")) main(location, geocoder, cache_db, "hourly", "f"))
app.add_url_rule('/plain/<location>', 'plain_location', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"c")))
app.add_url_rule('/plain/<location>/', 'plain_location/', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"c")))
app.add_url_rule('/plain/<location>/t', 'plain_today_location', lambda
location: strip_colors(main(location, geocoder, cache_db,
"hourly", "c")))
app.add_url_rule('/plain/f/<location>', 'plain_location_f', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"f")))
app.add_url_rule('/plain/f/<location>/', 'plain_location_f/', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"f")))
app.add_url_rule('/plain/f/<location>/t', 'plain_today_location_f', lambda
location: strip_colors(main(location, geocoder, cache_db,
"hourly", "f")))