mirror of https://gitlab.com/ceda_ei/sky
Change content type
This commit is contained in:
parent
9e86eee17d
commit
2613906e2c
|
@ -157,7 +157,10 @@ def index():
|
||||||
|
|
||||||
|
|
||||||
def main(location, geocoder, cache_db, kind, unit):
|
def main(location, geocoder, cache_db, kind, unit):
|
||||||
|
try:
|
||||||
coordinates = get_coordinates(location, geocoder, cache_db)
|
coordinates = get_coordinates(location, geocoder, cache_db)
|
||||||
|
except KeyError:
|
||||||
|
return "Location Not found"
|
||||||
weather = get_weather(coordinates)
|
weather = get_weather(coordinates)
|
||||||
text = weather_to_text(weather, kind, unit, coordinates[2])
|
text = weather_to_text(weather, kind, unit, coordinates[2])
|
||||||
return ("\n" + text + "\n\n" + config.source + "\nPowered by Dark Sky - "
|
return ("\n" + text + "\n\n" + config.source + "\nPowered by Dark Sky - "
|
||||||
|
@ -209,3 +212,9 @@ app.add_url_rule('/p/f/<location>/', 'plain_location_f/', lambda location:
|
||||||
app.add_url_rule('/p/f/<location>/t', 'plain_today_location_f', lambda
|
app.add_url_rule('/p/f/<location>/t', 'plain_today_location_f', lambda
|
||||||
location: strip_colors(main(location, geocoder, cache_db,
|
location: strip_colors(main(location, geocoder, cache_db,
|
||||||
"hourly", "f")))
|
"hourly", "f")))
|
||||||
|
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def after(response):
|
||||||
|
response.headers['Content-Type'] = "text/plain; charset=utf-8"
|
||||||
|
return response
|
||||||
|
|
Loading…
Reference in New Issue