Data Dashboard Example -- Temperature in Cambridge

In the Anvil.Works example app, ‘Data Dashboard’, the temperature in Cambridge is shown at about 300 degrees Fahrenheit !!

According to a StackOverflow answer, written by MFink, the temperature default is degrees Kelvin.

I say the code in ‘ServerModule1’ is incorrect.

Code as written

@anvil.server.callable
def get_weather_data(latitude, longitude):
  try:
    resp = anvil.http.request("https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&exclude=hourly,daily&appid=%s" 
        % (latitude, longitude, "43eda1fbcf0b07043eeeac93ae54e1e0"),
        json=True)
    # convert timestamp to datetime object

If Fahrenheit is desired, then the code should read

@anvil.server.callable
def get_weather_data(latitude, longitude):
  try:
    resp = anvil.http.request("https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&exclude=hourly,daily&appid=%s&units=imperial"
        % (latitude, longitude, "43eda1fbcf0b07043eeeac93ae54e1e0"),
        json=True)
    # convert timestamp to datetime object

Just for fun, here are a couple openweathermap.org API links

In Cambridge, degrees Kelvin

In Cambridge, degrees Fahrenheit

Thanks @khoitsma, we’ll get that updated! :slight_smile: