This is a Weather Information System that give weather information about few famous cities of India.
Pre-requisites:
-
Golang 1.12
-
GORM
go get -u github.com/jinzhu/gorm
-
API token for
http://api.openweathermap.org
Steps to run:
- Signup on
http://api.openweathermap.org
, get the API token and set the environment variableAPIKEY
export APIKEY=<API-TOKEN>
2. Simply run run.sh
script. After that system is ready to handle requests.
Description:
-
This application runs as a local http sever at 8080 port and continously gathers data in the background from
http://api.openweathermap.org
in goroutines. -
It saves data in
mysql
container running on the localhost and the container port3306
is mapped to port3306
of localhost. -
Weather information for a particular city can be queried in 3 ways
a. with
city name
b. with
latitute
andlongitude
c. with
zip-code
So the applicatin exposes 3 endpoints for the user:
a. http://localhost:8080/weather/?city=`cityname`
b. http://localhost:8080/weather/?lat=`latitude`&lon=`longitude`
Note: There is a .http
file in this project to make sample API calls to sever