Giter Site home page Giter Site logo

rainfall-service's Introduction

rainfall-service [Get rainfall readings across Singapore]

Overview

It is a simple web application that extracts rainfall data of a particular location across Singapore, such as Gardens by the Bay (with address Marina Gardens Drive). The real-time weather readings can be found at https://api.data.gov.sg/v1/environment/rainfall.

The application is developed as a webservice to serve the selected rainfall data over HTTP using Flask, a micro web framework written in Python.

It uses a config file(config.yaml) as an input with the below 2 entries

url: https://api.data.gov.sg/v1/environment/rainfall
location: Marina Gardens Drive

Output

Location, Time, Rainfall Amount, Raining/Not Raining

Example:

When the app is running, calling http://localhost:8080 will return the current data for the given location, as a single line:

Marina Gardens Drive, 08:45, 0.2mm, Raining

Installation, Setup and Run

On Physical machine/ VM

Clone the repo

git clone https://github.com/dd18/rainfall-service.git 

Install the python dependencies

cd rainfall-service/
pip install -r requirements.txt

Run the application

python service/app.py

Test

curl -X GET http://localhost:8080

On Docker

Clone the repo

git clone https://github.com/dd18/rainfall-service.git

Create the docker image

cd rainfall-service/
docker build -t rainfallsvc .

Check the docker images

docker images

Run the app in the container

docker run -d -p 8080:8080 -v $(pwd)/conf/config.yaml:/app/conf/config.yaml --name rainfall rainfallsvc

Test

curl -X GET http://localhost:8080

On Kubernetes

rainfall docker image is pushed to dockerhub and is publicly available with the tag docklinux/rainfall. POD definition file pulls the docker image from dockerhub.

To pull the docker image

docker pull docklinux/rainfall

Create the namespace

kubectl create ns rainfall

Create the configmap

using config.yaml directly

git clone https://github.com/dd18/rainfall-service.git
cd rainfall-service/
kubectl create configmap rainfall-config --from-file conf/config.yaml -n rainfall

Or using manifest

git clone https://github.com/dd18/rainfall-service.git
cd rainfall-service/
kubectl apply -f manifests/rainfall-cm.yaml

Create the Pod

kubectl apply -f manifests/rainfall-pod.yaml

Port Forwarding

kubectl port-forward rainfall -n rainfall 8080:8080

Test

curl -X GET http://localhost:8080

rainfall-service's People

Contributors

dd18 avatar

Watchers

 avatar

Forkers

debasishdas033

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.