Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.51 KB

README.md

File metadata and controls

65 lines (46 loc) · 1.51 KB

Weather GO

Logo

Build Status codecov

Simple App that returns the Weather based on the Latitude and Longitude.

Before you start:

It is required to have an ENV Variable named CONFIG_PATH pointing to a YAML file with the following scructure.

Port: :8000       # the port you want
CacheExp: 5       # time in minutes to the cache expiration
CachePurge: 10    # time in minutes to the purge of expired cached weathers
DbFile: path/to/your/weather.db
WhiteListHosts:
  - host1
  - host2
OpenWeatherKeys:  # any number of keys you want
  - key1
  - key2
  - ...

You can find an example of this file here.

And now?

To Get the weather you should do a GET Request to:

HTTP GET http://localhost:8000/weather/{latitude}/{longitude}/{provider}

Example

HTTP GET http://localhost:8000/weather/52.1044634/-9.7957984/OPENWEATHER

Will result in:

{  
   "lat":"52.1044634",
   "lon":"-9.7957984",
   "temp":9.78,
   "location":"Killorglin",
   "humidity":94,
   "created_at":"2018-12-05T21:39:04.769538Z"
}

Getting from DockerHub

docker run -i -p 443:443 -e CONFIG_FILE='/usr/local/config_sample.yml' -v {PATH_TO_YOUR_LOCAL_YML_CONFIG}:/usr/local/config_sample.yml flaviojmendes/weather