Compare commits

...

3 Commits

Author SHA1 Message Date
Ceda EI fae99965c6 Change /plain to /p 2019-01-11 00:55:30 +05:30
Ceda EI 5d67e85b78 Update README, server.py for Windows update 2019-01-11 00:33:41 +05:30
Ceda EI d3f21f7ec0 Add /plain endpoints for windows 2019-01-11 00:31:37 +05:30
2 changed files with 32 additions and 0 deletions

View File

@ -13,3 +13,5 @@ To check weather for your location simply run the following command in a termina
### In Fahrenheit
+ Weather for one week - `curl sky.webionite.com/f/location`
+ Weather for today - `curl sky.webionite.com/f/location/t`
Replace sky.webionite.com/ with sky.webionite.com/p/ on Windows

View File

@ -150,6 +150,8 @@ def index():
"In Fahrenheit\n"
"+ Weather for one week - curl sky.webionite.com/f/location \n"
"+ Weather for today - curl sky.webionite.com/f/location/t\n\n"
"Replace sky.webionite.com/ with sky.webionite.com/p/ on "
"Windows \n\n"
+ config.source + "\n")
return text
@ -162,6 +164,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>', 'location', lambda location:
main(location, geocoder, cache_db, "daily", "c"))
@ -179,3 +185,27 @@ app.add_url_rule('/f/<location>/', 'location_f/', lambda location:
app.add_url_rule('/f/<location>/t', 'today_location_f', lambda location:
main(location, geocoder, cache_db, "hourly", "f"))
app.add_url_rule('/p/<location>', 'plain_location', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"c")))
app.add_url_rule('/p/<location>/', 'plain_location/', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"c")))
app.add_url_rule('/p/<location>/t', 'plain_today_location', lambda
location: strip_colors(main(location, geocoder, cache_db,
"hourly", "c")))
app.add_url_rule('/p/f/<location>', 'plain_location_f', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"f")))
app.add_url_rule('/p/f/<location>/', 'plain_location_f/', lambda location:
strip_colors(main(location, geocoder, cache_db, "daily",
"f")))
app.add_url_rule('/p/f/<location>/t', 'plain_today_location_f', lambda
location: strip_colors(main(location, geocoder, cache_db,
"hourly", "f")))